Flutter : Print two different data in two different network printers - flutter

I am building a KOT app using flutter. In this I need to split the data into two and send the data to two different thermal printers connected in same network.
Is this possible to do with flutter?
Data is printing in one printer with preview page.
final bytes = await pdf.save();
File file;
final dir = await getApplicationDocumentsDirectory();
file = File('${dir.path}/$name');
await file.writeAsBytes(bytes);
await Printing.layoutPdf(
onLayout: (PdfPageFormat format) async => pdf.save());
I want the data to print in two printers respectively directly without any previews

Related

How do I print network image in bluetooth printer in flutter?

I am adding local image from assets folder like this
`
final ByteData data= await rootBundle.load('assets/dol.jpg');
final bytes=data.buffer.asUint8List();
final image= img.decodeImage(bytes);
ticket.image(image);
`
but how can I add image from network to print in bluetooth iam using esc_pos_bluetooth for printing.

Flutter: How to generate screenshots in arbitrary resolutions?

In Flutter, how do you get a screenshot for an arbitrary screen resolution? I.e. for a screen resolution that's different from the resolution the app is running in?
Is there a way to tell the Flutter engine to paint a single frame into a buffer with a specific resolution?
What I'm trying to accomplish is to generate the screenshots for the various app stores from within the app, but without scaling and cropping screenshots that were taken for different devices/resolutions.
How would you tackle that requirement?
Any advise is welcome,
Thank you!
if you are talking about taking a screenshot of a particular widget and saving it
the you have to use renderrepaint boundry with key .
dependencies - path provider
Image gallery saver ..
takeScreenshot(BuildContext context,GlobalKey _key,String slug) async {
RenderRepaintBoundary boundary = _key.currentContext.findRenderObject();
ui.Image image = await boundary.toImage(pixelRatio: 3.0);
final snackBar = SnackBar(content: Text("Image saved to gallery"));
ScaffoldMessenger.of(context).showSnackBar(snackBar);
final directory = (await getApplicationDocumentsDirectory()).path;
ByteData byteData = await image.toByteData(format: ui.ImageByteFormat.png);
final result = await ImageGallerySaver.saveImage(
byteData.buffer.asUint8List(),
name: "name.jpg");
}

Is it possible to change the location of sorted video of image_picker plugin?

I am picking video from camera in this way. and using image_picker: ^0.6.7+22 plugin.
final _picker = ImagePicker();
Future<String> recordAndGetVideo()async{
PickedFile file = await _picker.getVideo(source: ImageSource.camera);
if(file != null){
return file.path;
}
return null;
}
After record ad video it stored the video and final path is this path. /storage/emulated/0/Android/data/com.example.app/files/Pictures/a190e227-a42c-4b09-bad8-4a9591454ff64584234230431626592.mp4
Now is it possible to store that video is different dir ? like /storage/emulated/0/Example App/a190e227-a42c-4b09-bad8-4a9591454ff64584234230431626592.mp4
Yes it is possible, But you have to re-write the file from one location to another.
This is the only way.

How do you download an image from the internet onto a file in Flutter?

I'm making a Flutter project where an image is displayed in listview and the user can share, favourite or download the image. I'm stuck on the downloading part. Is it possible to save an image file onto the phone's storage for offline use?
What I want to happen is I can create and write an image file
Future<String> get _localPath async {
final directory = await getApplicationDocumentsDirectory();
return directory.path;
}
Future<File> get _localFile async {
final path = await _localPath;
return File('$path/$title.txt');
}
// Write an image by obtaining an image through a URL
and then be able to access it through
Image.file('$path/$title.txt')

how to embed widgets to images and save it to the device

I have an image with a container on it. I want to be able to edit the TextField inside the container and save the image as an image to the device.
My current setup is a stack where I have the image and a container on top of each other. How can I save that as an image?
Note that I don't want to save the whole screen, just the image and whatever on it.
Future<File> createWave(BuildContext context, GlobalKey screen) async {
RenderRepaintBoundary boundary = screen.currentContext.findRenderObject();
ui.Image image = await boundary.toImage();
ByteData byteData = await image.toByteData(format: ui.ImageByteFormat.png);
Uint8List pngBytes = byteData.buffer.asUint8List();
final directory = (await getApplicationDocumentsDirectory()).path;
File imgFile = File('$directory/screenshot.png');
await imgFile.writeAsBytes(pngBytes);
return imgFile;
}
Thankfully since flutter uses skia to render it's graphics, we are able to take screenshots of widgets and there is already a really good article that does somethings similar. Basically you wrap your widget in a RepaintBoundary and assign it a key then use the key to call the RenderObject.toImage method. Here is another simple example to do this. It's amazing how simple it is :D