wip: null safety save files
parent
2ce020c019
commit
4618ad1994
File diff suppressed because one or more lines are too long
|
@ -10,13 +10,13 @@ Future<void> capturePng({required GlobalKey widgetKey}) async {
|
|||
widgetKey.currentContext!.findRenderObject() as RenderRepaintBoundary;
|
||||
final ui.Image image = await boundary.toImage(pixelRatio: 3.0);
|
||||
final ByteData byteData =
|
||||
await (image.toByteData(format: ui.ImageByteFormat.png) as Future<ByteData>);
|
||||
(await image.toByteData(format: ui.ImageByteFormat.png))!;
|
||||
await writeByteToImageFile(byteData);
|
||||
}
|
||||
|
||||
Future<String> writeByteToImageFile(ByteData byteData) async {
|
||||
final Directory dir = Platform.isAndroid
|
||||
? await (getExternalStorageDirectory() as Future<Directory>)
|
||||
? (await getExternalStorageDirectory())!
|
||||
: await getApplicationDocumentsDirectory();
|
||||
final File imageFile = File('${dir.path}/screenshot.png');
|
||||
// ignore: avoid_slow_async_io
|
||||
|
|
Reference in New Issue