fixing wireframe issue
This commit is contained in:
@@ -40,14 +40,17 @@ class DatabaseHelper {
|
|||||||
|
|
||||||
var openDb = await openDatabase(
|
var openDb = await openDatabase(
|
||||||
path,
|
path,
|
||||||
version: 1,
|
// OLD: version: 1,
|
||||||
onCreate: (db, version) => _createDatabaseTables(db),
|
version: 2,
|
||||||
|
// OLD: onCreate: (db, version) => _createDatabaseTables(db),
|
||||||
|
onCreate: (db, version) async => await _createDatabaseTables(db),
|
||||||
onUpgrade: (db, int oldversion, int newversion) async {
|
onUpgrade: (db, int oldversion, int newversion) async {
|
||||||
if (oldversion < newversion) {
|
if (oldversion < newversion) {
|
||||||
print("Version Upgrade");
|
// OLD: print("Version Upgrade");
|
||||||
|
await _createDatabaseTables(db);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
); // fix version upgrade + await table creation - by Azmat on 23-sep
|
||||||
|
|
||||||
// Check if the table exists
|
// Check if the table exists
|
||||||
// var tableResult = await openDb.query('sqlite_master',
|
// var tableResult = await openDb.query('sqlite_master',
|
||||||
@@ -71,7 +74,8 @@ class DatabaseHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _createDatabaseTables(Database db) async {
|
Future<void> _createDatabaseTables(Database db) async {
|
||||||
tablequery.createOtherTable(db);
|
// OLD: tablequery.createOtherTable(db);
|
||||||
|
await tablequery.createOtherTable(db); // await table creation before queries run - by Azmat on 23-sep
|
||||||
}
|
}
|
||||||
|
|
||||||
// create other table
|
// create other table
|
||||||
|
|||||||
@@ -43,7 +43,8 @@ class TableQuery {
|
|||||||
extn15 TEXT,
|
extn15 TEXT,
|
||||||
phone TEXT,
|
phone TEXT,
|
||||||
nme TEXT,
|
nme TEXT,
|
||||||
imageupload TEXT,
|
// OLD: imageupload TEXT,
|
||||||
|
imageupload TEXT // fix trailing comma sqlite error - by Azmat on 23-sep
|
||||||
|
|
||||||
)''');
|
)''');
|
||||||
} else {
|
} else {
|
||||||
@@ -81,7 +82,8 @@ class TableQuery {
|
|||||||
extn14 TEXT,
|
extn14 TEXT,
|
||||||
extn15 TEXT,
|
extn15 TEXT,
|
||||||
college TEXT,
|
college TEXT,
|
||||||
Name TEXT,
|
// OLD: Name TEXT,
|
||||||
|
Name TEXT // fix trailing comma sqlite error - by Azmat on 23-sep
|
||||||
|
|
||||||
)''');
|
)''');
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ class UniController {
|
|||||||
// entity['active'] = entity['active'] ? 1 : 0;
|
// entity['active'] = entity['active'] ? 1 : 0;
|
||||||
|
|
||||||
// Insert data
|
// Insert data
|
||||||
var entityId = await db.insert(tableName, entity);
|
// OLD: var entityId = await db.insert(tableName, entity);
|
||||||
|
var entityId = await db.insert(tableName, entity, conflictAlgorithm: ConflictAlgorithm.replace); // overwrite same id instead of crash - by Azmat on 23-sep
|
||||||
if (entityId != null && entityId > 0) {
|
if (entityId != null && entityId > 0) {
|
||||||
print('$tableName Id data is inserted. $tableName Id ID: $entityId');
|
print('$tableName Id data is inserted. $tableName Id ID: $entityId');
|
||||||
} else {
|
} else {
|
||||||
@@ -40,10 +41,12 @@ class UniController {
|
|||||||
print('multiple entity is com is $entities');
|
print('multiple entity is com is $entities');
|
||||||
|
|
||||||
for (var entity in entities) {
|
for (var entity in entities) {
|
||||||
insertEntity(entity, tableName);
|
// OLD: insertEntity(entity, tableName);
|
||||||
|
batch.insert(tableName, entity, conflictAlgorithm: ConflictAlgorithm.replace);
|
||||||
}
|
}
|
||||||
|
|
||||||
await batch.commit();
|
// OLD: await batch.commit();
|
||||||
|
await batch.commit(); // real batch write with overwrite - by Azmat on 23-sep
|
||||||
}
|
}
|
||||||
|
|
||||||
// update Entity
|
// update Entity
|
||||||
@@ -81,6 +84,11 @@ class UniController {
|
|||||||
return rowsAffected;
|
return rowsAffected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<int> deleteAll(String tableName) async {
|
||||||
|
Database db = await conn.database;
|
||||||
|
return await db.delete(tableName); // clear table for fresh server sync - by Azmat on 23-sep
|
||||||
|
}
|
||||||
|
|
||||||
// get count
|
// get count
|
||||||
Future<int> getDataCount(String tableNmae) async {
|
Future<int> getDataCount(String tableNmae) async {
|
||||||
Database db = await conn.database;
|
Database db = await conn.database;
|
||||||
|
|||||||
+8
-1
@@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:sqflite/sqflite.dart';
|
import 'package:sqflite/sqflite.dart';
|
||||||
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
|
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
|
||||||
@@ -21,10 +23,15 @@ import 'screens/splash_screen/splash_screen.dart';
|
|||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
// OLD: print(sqlite3.version);
|
||||||
|
// OLD: sqfliteFfiInit();
|
||||||
|
// OLD: // Initialize the database factory for sqflite_common_ffi
|
||||||
|
// OLD: databaseFactory = databaseFactoryFfi;
|
||||||
|
if (!kIsWeb && !Platform.isAndroid && !Platform.isIOS) { // ffi only for desktop, mobile uses native sqflite - by Azmat on 23-sep
|
||||||
print(sqlite3.version);
|
print(sqlite3.version);
|
||||||
sqfliteFfiInit();
|
sqfliteFfiInit();
|
||||||
// Initialize the database factory for sqflite_common_ffi
|
|
||||||
databaseFactory = databaseFactoryFfi;
|
databaseFactory = databaseFactoryFfi;
|
||||||
|
}
|
||||||
|
|
||||||
//Request notification permissions
|
//Request notification permissions
|
||||||
// await _requestNotificationPermissions();
|
// await _requestNotificationPermissions();
|
||||||
|
|||||||
Reference in New Issue
Block a user