initFromNetwork method

Future<void> initFromNetwork({
  1. Uri? archiveUri,
  2. bool forceUpdate = false,
  3. int? timeout,
})

Load from downloaded JMdict.gz file

Defaults to downloading JMdict.gz file from http://ftp.edrdg.org/pub/Nihongo/JMdict.gz Enabling forceUpdate will append/update into existing local Database if exists No timeout is enforced during the download process by default. The timeout itself is represented in seconds.

Implementation

Future<void> initFromNetwork({
  Uri? archiveUri,
  bool forceUpdate = false,
  int? timeout,
}) async {
  if (_isInitialized || _isLoading) {
    _warnAlreadyInitialized();
    return;
  }
  _isLoading = true;
  final store = await openStore();
  final box = store.box<JMDictEntryImpl>();
  if (box.isEmpty() || (!box.isEmpty() && forceUpdate)) {
    await _updater.update(
      loader: _loader,
      store: store,
      alternativeDownloadUrl: archiveUri?.toString(),
      timeout: timeout,
    );
  }
  _store = store;
  _isInitialized = true;
  _isLoading = false;
}