createDatabase static method

Future<MessageRepository> createDatabase(
  1. String dbName
)

Implementation

static Future<MessageRepository> createDatabase(String dbName) async {
  MessageRepository messageRepository;

  if (!wasInitialized) {
    if (Platform.isWindows || Platform.isLinux) {
      // Initialize FFI
      sqfliteFfiInit();

      // Change the default factory. On iOS/Android, if not using `sqlite_flutter_lib` you can forget
      // this step, it will use the sqlite version available on the system.
      databaseFactory = databaseFactoryFfi;
    }
  }
  messageRepository = MessageRepository(await openDatabase(
    '${await getDatabasesPath()}/$dbName',
    onCreate: _createTables,
    version: 1,
  ));
  return messageRepository;
}