wip: null safety save files

upgrade-2021-project
Stefan Haslinger 2022-03-14 10:07:16 +01:00
parent 2ce020c019
commit 4618ad1994
2 changed files with 3 additions and 3 deletions

File diff suppressed because one or more lines are too long

View File

@ -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