Created
March 1, 2020 01:06
-
-
Save tomalabaster/fde073ac0490c685e143e1cfb4ea060e to your computer and use it in GitHub Desktop.
GOOD: Async init done in main method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() async { | |
WidgetsFlutterBinding.ensureInitialized(); | |
var databasesPath = await getDatabasesPath(); | |
var path = join(databasesPath, 'example.db'); | |
var database = await openDatabase(path, version: 1, onCreate: (db, version) async { | |
await db.execute('''CREATE TABLE MyTable ( | |
id INTEGER PRIMARY KEY, | |
name TEXT)'''); | |
}); | |
runApp(MyApp(database: database)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment