pdfrxFlutterInitialize function
Future<void>
pdfrxFlutterInitialize({
- @Deprecated('WASM modules are now only included in web builds. This flag now does nothing.') bool dismissPdfiumWasmWarnings = false,
- bool processWidePdfiumGate = false,
Explicitly initializes the Pdfrx library for Flutter.
This function actually sets up the following functions:
- Pdfrx.loadAsset: Loads an asset by name and returns its byte data.
- Pdfrx.cacheDirectoryPath: The path to the temporary directory for caching (For Web, it is not applicable).
- Call PdfrxEntryFunctions.init to initialize the library.
Set processWidePdfiumGate on every Flutter engine before initialization
when using desktop_multi_window. See Pdfrx.useProcessWidePdfiumGate.
For Dart (non-Flutter) programs, you should call pdfrxInitialize instead.
Implementation
Future<void> pdfrxFlutterInitialize({
@Deprecated('WASM modules are now only included in web builds. This flag now does nothing.')
bool dismissPdfiumWasmWarnings = false,
/// See [Pdfrx.useProcessWidePdfiumGate].
bool processWidePdfiumGate = false,
}) async {
if (processWidePdfiumGate) {
Pdfrx.useProcessWidePdfiumGate = true;
}
if (_isInitialized) return;
WidgetsFlutterBinding.ensureInitialized();
if (pdfrxEntryFunctionsOverride != null) {
PdfrxEntryFunctions.instance = pdfrxEntryFunctionsOverride!;
}
Pdfrx.loadAsset ??= (name) async {
final asset = await rootBundle.load(name);
return asset.buffer.asUint8List();
};
if (!kIsWeb) {
Pdfrx.cacheDirectoryPath ??= await getCacheDirectory();
}
/// NOTE: it's actually async, but hopefully, it finishes quickly...
await platformInitialize();
_isInitialized = true;
}