I have a web application where the user answered a questionnaire, I managed to convert all this widget that I created into an image, now I would like to open that chrome popup to print only that specific image that I created
Here is the code example where I can convert the entire widget into an image, now I would just like to print this image by making the Chrome browser do what it does with the shortcut ctrl + p, however, passing my image instead of the entire screen
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:login_example/presentation/component/custom_input.dart';
import 'package:login_example/presentation/component/loading_button.dart';
import 'package:widgets_to_image/widgets_to_image.dart';
class ApplicationExapmle extends StatelessWidget {
const ApplicationExapmle({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
WidgetsToImageController controller = WidgetsToImageController();
return WidgetsToImage(
controller: controller,
child: Column(
children: [
Center(
child: Text("test"),
),
SizedBox(height: 20),
Center(
child: CustomInput(controller: TextEditingController()),
),
LoadingButton(onTap: () async {
var image = await controller.capture();
}, textButton: "save")
],
),
);
}
}
I tried using the print lib:https://pub.dev/packages/printing, but what I really wanted was to print this image that I managed to convert
Here is the code I am using to generate a QR Code image and get base64 string out of it and then open the print window for that image only in flutter web, you can tweak it to your needs:
Here is "toQrImageData" function:
I am using qr_flutter package for qr code related work.