initFromAsset method

Future<void> initFromAsset({
  1. required String assetPath,
  2. bool forceUpdate = false,
})

Load pre-existing JMdict.gz file from existing Flutter assetPath

Enabling forceUpdate will append/update into existing local Database if exists

Implementation

Future<void> initFromAsset({required String assetPath, bool forceUpdate = false,}) async {
  if (_isInitialized || _isLoading) {
    _warnAlreadyInitialized();
    return;
  }
  _isLoading = true;
  try {
    final store = await openStore();
    final box = store.box<JMDictEntryImpl>();
    if (box.isEmpty() || !box.isEmpty() && forceUpdate) {
      await _load(assetPath, store,);
    }
    _store = store;
    _isInitialized = true;
  } catch (err) {
    rethrow;
  } finally {
    _isLoading = false;
  }
}