Flutter의 Moor~MyDatabase multipletimes.WARNING이 나타날 때의 대응 방법

2986 단어 Fluttermoortech
Flutter Moor에 다음 WARNING이 나왔어요.
flutter: WARNING (moor): It looks like you've created the database class MyDatabase multiple times. When these two databases use the same QueryExecutor, race conditions will occur and might corrupt the database. 
Try to follow the advice at https://moor.simonbinder.eu/faq/#using-the-database or, if you know what you're doing, set moorRuntimeOptions.dontWarnAboutMultipleDatabases = true
데이터베이스 클래스가 단식으로 생성되지 않을 때 나타나는 WARNING.
하면, 만약, 만약...
대응 방법은 상술한 기록에 기재되어 있는데, 어디에 쓰입니까?따라서 해결 로그로 저장합니다.
Moor의OpenConnection 메서드에 기재되어 있습니다.
내 예야.
LazyDatabase _openConnection() {
  // the LazyDatabase util lets us find the right location for the file async.
  return LazyDatabase(() async {
    // put the database file, called db.sqlite here, into the documents folder
    // for your app.
    final dbFolder = await getApplicationDocumentsDirectory();
    final file = File(p.join(dbFolder.path, 'db.sqlite'));
    moorRuntimeOptions.dontWarnAboutMultipleDatabases = true;
    return VmDatabase(file);
  });
}

좋은 웹페이지 즐겨찾기