Skip to content

Commit

Permalink
comment out saving file to local
Browse files Browse the repository at this point in the history
  • Loading branch information
sukso96100 committed Jul 13, 2024
1 parent 38c51f5 commit 5c78c1a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/printclient.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,21 @@ import 'dart:typed_data';
import 'dart:ui';
import 'package:http/http.dart' as http;
import 'package:http_parser/http_parser.dart';
import 'package:shared_preferences/shared_preferences.dart';

Future<int> printImageToLabel(
Uint8List imageUint8List, int vendorId, int productId) async {
var prefs = await SharedPreferences.getInstance();
var widthMm = prefs.getInt('printCanvasWidthMm') ?? 70;
var heightMm = prefs.getInt('printCanvasHeightMm') ?? 70;
var canvasDpi = prefs.getInt('printCanvasDpi') ?? 203;

var url = Uri.parse(
"http://0.0.0.0:5000/print/$vendorId/$productId?print_canvas_width_mm=70&print_canvas_height_mm=70&margin_top_px=0&margin_left_px=0&print_dpi=203");
"http://0.0.0.0:5000/print/$vendorId/$productId?print_canvas_width_mm=$widthMm&print_canvas_height_mm=$heightMm&margin_top_px=0&margin_left_px=0&print_dpi=$canvasDpi");
// imageToPrint to uint8list
// var imgByteData = await imageToPrint.toByteData(format: ImageByteFormat.png);
// var imageUnit8List = imgByteData!.buffer.asUint8List();
File origFile = File("./image_flutter.png")..writeAsBytesSync(imageUint8List);
// File origFile = File("./image_flutter.png")..writeAsBytesSync(imageUint8List);
var multipartFile = http.MultipartFile.fromBytes("image", imageUint8List,
filename: 'label.png', contentType: MediaType.parse('image/png'));
var request = http.MultipartRequest("POST", url);
Expand Down

0 comments on commit 5c78c1a

Please sign in to comment.