• 0

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191


File: /var/www/html/cnasolution/site/application/views/question.php
Line: 191
Function: _error_handler

File: /var/www/html/cnasolution/site/application/controllers/Questions.php
Line: 419
Function: view

File: /var/www/html/cnasolution/site/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

Initialized database still returns as null [Flutter, sqflite]

I'm trying to perform CRUD operations on Flutter, using the sqflite library. Online resources point towards a bunch of ways to go about this. Here is my implementation:

class SqlManager {   static const String tname = 'table1';  static const String dname = 'database.db';  Future db;   initDB() async {    Directory path = await getApplicationDocumentsDirectory();    db = openDatabase(join(path.path, dname), version: 1, onCreate: (db, version) {      return db.execute(          'CREATE TABLE $tname (id INTEGER PRIMARY KEY, name TEXT, type TEXT, time1 INTEGER, time2 INTEGER, imp INTEGER, urg INTEGER)');    });  }   Future writing(Task task) async {    print("called");    final Database DB = await db;    await DB.insert(      tname,      task.toMap(),      conflictAlgorithm: ConflictAlgorithm.replace,    );    print("Execution completed");  }   Future> reading() async {    Database DB = await db;    List> maps = await DB.query(tname);    return List.generate(maps.length, (i) {      return Task.fromMap(maps[i]);    });  } }  

Whenever I attempt to call any of these functions, I hit upon a NoSuchMethodError, thrown by the variable 'DB' inside one of these functions. Any help is appreciated, thanks!

Download script demo [LINK] [Origin]
Download script demo [LINK 2] [Onedrive] Download script demo [LINK 2] [Google drive]