import 'dart:async';
|
|
import 'package:flutter/widgets.dart';
|
|
import 'package:path/path.dart';
|
|
import 'package:sqflite/sqflite.dart';
|
|
|
|
Future<Database> getDatabaseConnection() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
final database = openDatabase(
|
|
// Set the path to the database. Note: Using the `join` function from the
|
|
// `path` package is best practice to ensure the path is correctly
|
|
// constructed for each platform.
|
|
join(await getDatabasesPath(), 'envelope.db'),
|
|
// When the database is first created, create a table to store dogs.
|
|
onCreate: (db, version) {
|
|
// Run the CREATE TABLE statement on the database.
|
|
return db.execute(
|
|
'''
|
|
CREATE TABLE IF NOT EXISTS friends(
|
|
id BLOB PRIMARY KEY,
|
|
user_id BLOB,
|
|
friend_id BLOB,
|
|
friend_id_decrypted BLOB,
|
|
accepted_at TEXT
|
|
);
|
|
''',
|
|
);
|
|
},
|
|
// Set the version. This executes the onCreate function and provides a
|
|
// path to perform database upgrades and downgrades.
|
|
version: 1,
|
|
);
|
|
|
|
return database;
|
|
}
|