openFuture<T> static method
Widget
openFuture<T>(
- Future<
T> getFuture(), - Future<
PdfDocument> futureToDocument(- T
- Key? key,
- PdfViewerController? viewerController,
- PdfViewerParams? params,
- OnError? onError,
- Widget loadingBannerBuilder()?,
- PdfDocument? docFallback,
Open PDF using async function.
Implementation
static Widget openFuture<T>(
Future<T> Function() getFuture,
Future<PdfDocument> Function(T) futureToDocument, {
Key? key,
PdfViewerController? viewerController,
PdfViewerParams? params,
OnError? onError,
Widget Function(BuildContext)? loadingBannerBuilder,
PdfDocument? docFallback,
}) =>
FutureBuilder<T>(
key: key,
future: getFuture(),
builder: (context, snapshot) {
final data = snapshot.data;
if (data != null) {
return PdfViewer(
doc: futureToDocument(data),
viewerController: viewerController,
params: params,
onError: onError,
);
} else if (loadingBannerBuilder != null) {
return Builder(builder: loadingBannerBuilder);
} else if (docFallback != null) {
return PdfViewer(
doc: Future.value(docFallback),
viewerController: viewerController,
params: params,
onError: onError,
);
}
return Container(); // ultimate fallback
},
);