How can I bundle a pre-populated Realm database in a Flutter app?

I have a Flutter application that uses a pre-populated Realm database. Running flutter run -d <some-device> only install the app without the pre-populated database. How can I install the pre-populated Realm database into a mobile device together with the Flutter app?

Hi Tembo_Nyati,
you can try to add the realm file to the Flutter app assets. But it is also possible to use initialDataCallback to populate your initial data once the Realm is opened for the first time.

var config = Configuration.local([Dog.schema], initialDataCallback: (realm) {

I hope it will help.

Cross post over to SO

The answer above mentions the same solution as on StackOverflow; the Realm file needs to be included in your project assets - we may be more help if we knew about your development environment. XCode? Android Studio? Something else?

@Jay, I’m on Windows 11 x64, Flutter 3.0.5, Realm 0.3.1+beta, Visual Studio Code with Flutter and Dart extensions.

Hi @Tembo_Nyati,
I prepared a Flutter app that demonstrates bundling a pre-polluted realm in Flutter assets.
You can find out some other approach also.
I’m sorry about the delay.
Have a nice week!