Untitled

mail@pastecode.io avatar
unknown
plain_text
9 days ago
844 B
2
Indexable
Never
import 'dart:io';

import 'package:sqflite/sqflite.dart';

class DatabaseHelper {
  static final _databaseName = 'bachelors.db';
  static final _dbVersion = 1;

  static final _tableName = 'gradetable';

//column
  static final columnId = 'id';
  static final columnSemester = '';
  static final columnSemGrade = '';

  DatabaseHelper._privateConstructor(); //ways to make singleton
  static final DatabaseHelper instance = DatabaseHelper._privateConstructor();

  static Database? _database;

 Future<Database> get database async =>
      _database ??= await _initiateDatabase();

      Future<Database> _initiateDatabase() async {
    Directory directory = await getApplicationDocumentsDirectory();
    String path = join(directory.path, _databaseName);
    return await openDatabase(path, version: _dbVersion, onCreate: _onCreate);
  }
  
}
Leave a Comment