fixing wireframe issue

This commit is contained in:
Azmat-7860
2026-09-23 23:04:22 +05:30
parent 012969ae21
commit 90a8524b83
4 changed files with 37 additions and 16 deletions
+9 -5
View File
@@ -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
+6 -4
View File
@@ -43,9 +43,10 @@ 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 {
print('$tableName table exist'); print('$tableName table exist');
} }
@@ -81,9 +82,10 @@ 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 {
print('$tableName table exist'); print('$tableName table exist');
} }
+11 -3
View File
@@ -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;
+11 -4
View File
@@ -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();
print(sqlite3.version); // OLD: print(sqlite3.version);
sqfliteFfiInit(); // OLD: sqfliteFfiInit();
// Initialize the database factory for sqflite_common_ffi // OLD: // Initialize the database factory for sqflite_common_ffi
databaseFactory = databaseFactoryFfi; // 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);
sqfliteFfiInit();
databaseFactory = databaseFactoryFfi;
}
//Request notification permissions //Request notification permissions
// await _requestNotificationPermissions(); // await _requestNotificationPermissions();