Open ganeshchenniah opened 3 years ago
Looks like there is issue with Picture.toImage()
rendering. I was not able to fix it at the moment.
This issue sugests accomodating device pixel ratio into calculation but that was not helping in our case.
If anyone is looking for a workaround. You can do something like this with the pixel ratio MartinHlavna mentioned to get a higher resolution.
import 'dart:ui' as ui;
class _SignaturePageState extends State<SignaturePage> {
GlobalKey globalKey = GlobalKey();
RepaintBoundary(
key: globalKey,
child: Signature(
controller: _controller,
backgroundColor: Colors.white,
),
);
IconButton(
icon: const Icon(Icons.check),
color: Colors.blue,
onPressed: () async {
final RenderRepaintBoundary? boundary = globalKey.currentContext?.findRenderObject() as RenderRepaintBoundary?;
ui.Image? image = await boundary?.toImage(pixelRatio: 3);
ByteData? byteData = await image?.toByteData(format: ui.ImageByteFormat.png);
Uint8List? pngBytes = byteData?.buffer.asUint8List();
if (pngBytes != null) {
await Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: Center(
child: Image.memory(pngBytes),
),
);
},
),
);
}
},
),
how send http multipart request?