Loading assets in Flutter for desktop (Windows)

  assets, flutter, sqflite, sqlite, windows

I am trying to load SQLite DB in Flutter for Windows (it’s working on Android), but I receive an exception, my code is :

// Copy from asset
ByteData data = await rootBundle.load(join("assets", "mydb.sqlite"));
List<int> bytes = data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes);

I receive this exception :

[ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception:
Unable to load asset: assetsmydb.sqlite
#0 PlatformAssetBundle.load (package:flutter/src/services/asset_bundle.dart:224:7)
#1 DatabaseHelper._initDatabase (package:myapp/database_helper.dart:54:11)
#2 DatabaseHelper.database (package:myapp/database_helper.dart:29:17)
#3 DatabaseHelper.queryAllRows (package:myapp/database_helper.dart:80:19)
#4 _MyHomePageState._query (package:myapp/main.dart:193:15)

Source: Windows Questions

LEAVE A COMMENT