@@ -19,7 +19,7 @@ class DBHelper { | |||||
if (_db == null) _db = await initDb(); | if (_db == null) _db = await initDb(); | ||||
return _db; | return _db; | ||||
} | } | ||||
backupDb(context) async{ | |||||
backupDb({context}) async{ | |||||
var result = {"STATUS":0,"MSG":"Backup gagal!"}; | var result = {"STATUS":0,"MSG":"Backup gagal!"}; | ||||
var stock_id = prefs.getString(keyClass.stock_id)??''; | var stock_id = prefs.getString(keyClass.stock_id)??''; | ||||
if(stock_id != ''){ | if(stock_id != ''){ | ||||
@@ -226,6 +226,14 @@ class DBHelper { | |||||
final database = await db; | final database = await db; | ||||
var res = await database.update("${tableName.master}", unitUpdate.toJson(), | var res = await database.update("${tableName.master}", unitUpdate.toJson(), | ||||
where: "${columnName.id} = ?", whereArgs: [unitUpdate.id]); | where: "${columnName.id} = ?", whereArgs: [unitUpdate.id]); | ||||
// print('Row Updated'); | |||||
var checkCount = await database.query(tableName.master,where: "${columnName.flag} = ?", whereArgs: ['TRUE']); | |||||
// print(["check count",checkCount.length]); | |||||
if(checkCount.isNotEmpty&& checkCount.length%5==0){ | |||||
// print('auto backup file'); | |||||
backupDb(); | |||||
} | |||||
print('Row Updated'); | print('Row Updated'); | ||||
return res; | return res; | ||||
} | } | ||||
@@ -310,7 +310,7 @@ class Util{ | |||||
} | } | ||||
permissionCheck(context,pHandler.Permission permissionType,ifGranted,{customMessage=''})async{ | permissionCheck(context,pHandler.Permission permissionType,ifGranted,{customMessage=''})async{ | ||||
pHandler.PermissionStatus permission = await permissionType.status; | pHandler.PermissionStatus permission = await permissionType.status; | ||||
if(permission!= pHandler.PermissionStatus.granted){ | |||||
if(permission!= pHandler.PermissionStatus.granted &&context != null){ | |||||
if(permission== pHandler.PermissionStatus.denied || permission== pHandler.PermissionStatus.restricted){ | if(permission== pHandler.PermissionStatus.denied || permission== pHandler.PermissionStatus.restricted){ | ||||
showFlushbar(context,'${permissionType.toString().substring(permissionType.toString().lastIndexOf('.')+1)} permission is needed$customMessage. Please grant the permission!'); | showFlushbar(context,'${permissionType.toString().substring(permissionType.toString().lastIndexOf('.')+1)} permission is needed$customMessage. Please grant the permission!'); | ||||
await Future.delayed(Duration(seconds: 3)); | await Future.delayed(Duration(seconds: 3)); | ||||
@@ -634,7 +634,7 @@ class _HomePageState extends State<HomePage> { | |||||
], | ], | ||||
)); | )); | ||||
if(isBackup??false){ | if(isBackup??false){ | ||||
var result = await DBHelper.database.backupDb(context); | |||||
var result = await DBHelper.database.backupDb(context: context); | |||||
util.showFlushbar(context, result['MSG'],color: result["STATUS"]==1?Colors.grey:Colors.red); | util.showFlushbar(context, result['MSG'],color: result["STATUS"]==1?Colors.grey:Colors.red); | ||||
} | } | ||||
} | } | ||||
@@ -600,7 +600,7 @@ class _UnitDetailsState extends State<UnitDetails> { | |||||
String errMsg = ''; | String errMsg = ''; | ||||
util.showLoading(context); | util.showLoading(context); | ||||
await Future.sync(()async{ | await Future.sync(()async{ | ||||
if(currentPosisiton!=null) { | |||||
if(currentPosisiton!=null){ | |||||
if(blobList.where((element) => element.blob_file!=null).length==blobList.length){ | if(blobList.where((element) => element.blob_file!=null).length==blobList.length){ | ||||
for(int i = 0 ; i<blobList.length;i++){ | for(int i = 0 ; i<blobList.length;i++){ | ||||
blobList[i].lat = currentPosisiton.latitude.toString(); | blobList[i].lat = currentPosisiton.latitude.toString(); | ||||
@@ -1,7 +1,7 @@ | |||||
name: unitstocks | name: unitstocks | ||||
description: App to stock Thamrin Brothers Units | description: App to stock Thamrin Brothers Units | ||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html | ||||
version: 1.0.7+15 | |||||
version: 1.0.8+17 | |||||
environment: | environment: | ||||
sdk: ">=2.1.0 <3.0.0" | sdk: ">=2.1.0 <3.0.0" | ||||