Created
June 5, 2021 22:59
-
-
Save VB10/f5671bef0fa18ace683aba32abd8b708 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Future<Uint8List?> fetchData() async { | |
final data = await homeService.downloadFile(model.document ?? ''); | |
return data; | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
floatingActionButton: buildFloatingActionButtonDownlaod(), | |
appBar: AppBar(title: Text(model.title ?? '')), | |
body: fetchData().toBuild<Uint8List?>( | |
onSuccess: (data) { | |
if (data != null) { | |
return PdfView(controller: PdfController(document: PdfDocument.openData(data))); | |
} else { | |
return buildErrorWidget(); | |
} | |
}, | |
loadingWidget: CircularProgressIndicator(), | |
notFoundWidget: buildErrorWidget(), | |
onError: buildErrorWidget()), | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment