@@ -8,6 +8,8 @@ | |||||
<uses-permission android:name="android.permission.INTERNET"/> | <uses-permission android:name="android.permission.INTERNET"/> | ||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> | <uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> | ||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> | <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> | ||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | |||||
<application | <application | ||||
android:name="io.flutter.app.FlutterApplication" | android:name="io.flutter.app.FlutterApplication" | ||||
android:label="unitstocks" | android:label="unitstocks" | ||||
@@ -1,11 +1,13 @@ | |||||
import 'dart:async'; | import 'dart:async'; | ||||
import 'dart:io' as io; | import 'dart:io' as io; | ||||
import 'dart:typed_data'; | |||||
import 'UnitModel.dart'; | import 'UnitModel.dart'; | ||||
import 'package:path/path.dart'; | import 'package:path/path.dart'; | ||||
import 'package:path_provider/path_provider.dart'; | import 'package:path_provider/path_provider.dart'; | ||||
import 'package:sqflite/sqflite.dart'; | import 'package:sqflite/sqflite.dart'; | ||||
import 'Prefs.dart'; | import 'Prefs.dart'; | ||||
import '../main.dart'; | import '../main.dart'; | ||||
import 'package:permission_handler/permission_handler.dart' as pHandler; | |||||
class DBHelper { | class DBHelper { | ||||
DBHelper._(); | DBHelper._(); | ||||
@@ -15,18 +17,45 @@ class DBHelper { | |||||
Future<Database> get db async { | Future<Database> get db async { | ||||
if (_db == null) _db = await initDb(); | if (_db == null) _db = await initDb(); | ||||
return _db; | |||||
} | |||||
backupDb() async{ | |||||
try{ | try{ | ||||
//backupDatabase | |||||
String backupPath = join(_db.path.substring(0,_db.path.indexOf("/Android"))+"/Download/UnitDBBackup/", "${prefs.getString(keyClass.stock_id)}_UnitStocking.db"); | |||||
io.File dbFile = io.File(_db.path); | |||||
dbFile.copySync(backupPath); | |||||
// if(dbPath == null || dbPath == ''){ | |||||
final database = await db; | |||||
var dbPath = database.path; | |||||
await DBHelper.database.closeDb(); | |||||
// } | |||||
await prefs.remove(keyClass.backup_stock_id); | |||||
var stock_id = prefs.getString(keyClass.stock_id)??''; | |||||
if(stock_id != ''){ | |||||
var cabang = prefs.getString(keyClass.cabang_id)??''; | |||||
if(cabang !='' && cabang != null ) await prefs.setString(keyClass.backup_cabang_id,cabang); | |||||
if(stock_id !='' && stock_id != null ) await prefs.setString(keyClass.backup_stock_id,stock_id); | |||||
//backupDatabase | |||||
String backupPath = join(dbPath.substring(0,dbPath.indexOf("/Android"))+"/Download", "${prefs.getString(keyClass.backup_stock_id)}_UnitStocking.db"); | |||||
io.File backupFile = new io.File(backupPath); | |||||
io.File dbFile = io.File(dbPath); | |||||
if(dbFile.existsSync()){ | |||||
// dbFile.copySync(backupPath); | |||||
Uint8List byte = dbFile.readAsBytesSync(); | |||||
backupFile.writeAsBytesSync(byte); | |||||
return {"STATUS":1,"MSG":"Backup Berhasil!"}; | |||||
} | |||||
else{ | |||||
return {"STATUS":0,"MSG":"Backup gagal data unit tidak ditemukan!"}; | |||||
print('file backup dont exist tho'); | |||||
} | |||||
} | |||||
else{ | |||||
return {"STATUS":0,"MSG":"Backup gagal data unit tidak ditemukan!"}; | |||||
} | |||||
} | } | ||||
catch(e){ | catch(e){ | ||||
print(e); | print(e); | ||||
return {"STATUS":0,"MSG":"Backup gagal!"}; | |||||
} | } | ||||
return _db; | |||||
} | } | ||||
initDb() async { | initDb() async { | ||||
io.Directory documentsDirectory = await getExternalStorageDirectory(); | io.Directory documentsDirectory = await getExternalStorageDirectory(); | ||||
String path = join(documentsDirectory.path, "UnitStocking.db"); | String path = join(documentsDirectory.path, "UnitStocking.db"); | ||||
@@ -35,22 +64,37 @@ class DBHelper { | |||||
} | } | ||||
restoreDb()async{ | restoreDb()async{ | ||||
await closeDb(); | |||||
io.Directory documentsDirectory = await getExternalStorageDirectory(); | |||||
String backupPath = join(documentsDirectory.path.substring(0,documentsDirectory.path.indexOf("/Android"))+"/Download/UnitDBBackup/", "${prefs.getString(keyClass.stock_id)}_UnitStocking.db"); | |||||
io.File backupdbFile = io.File(backupPath); | |||||
if(backupdbFile.existsSync()){ | |||||
String path = join(documentsDirectory.path, "UnitStocking.db"); | |||||
backupdbFile.copySync(path); | |||||
return {"STATUS":1,"MSG":"File Back up successfull"}; | |||||
var result = {"STATUS":0,"MSG":"File Backup tidak ditemukan!"}; | |||||
if(prefs.getString(keyClass.stock_id) == null || prefs.getString(keyClass.stock_id) == prefs.getString(keyClass.backup_cabang_id)){ | |||||
if(prefs.getString(keyClass.backup_stock_id)!=null && prefs.getString(keyClass.backup_cabang_id)!= null){ | |||||
await util.permissionCheck(context,pHandler.Permission.storage,()async{ | |||||
io.Directory documentsDirectory = await getExternalStorageDirectory(); | |||||
String backupPath = join(documentsDirectory.path.substring(0,documentsDirectory.path.indexOf("/Android"))+"/Download", "${prefs.getString(keyClass.backup_stock_id)}_UnitStocking.db"); | |||||
io.File backupdbFile = io.File(backupPath); | |||||
if(backupdbFile.existsSync()){ | |||||
io.File dbFile = new io.File(join(documentsDirectory.path, "UnitStocking.db")); | |||||
Uint8List byte = backupdbFile.readAsBytesSync(); | |||||
dbFile.writeAsBytesSync(byte); | |||||
result = {"STATUS":1,"MSG":"File Back up successfull"}; | |||||
await DBHelper.database.closeDb(); | |||||
} | |||||
else result = {"STATUS":0,"MSG":"File Backup tidak ditemukan!"}; | |||||
},customMessage: " untuk menyimpan data backup"); | |||||
} | |||||
} | } | ||||
return {"STATUS":0,"MSG":"File Backup tidak ditemukan!"}; | |||||
else result = {"STATUS":0,"MSG":"File Backup tidak ditemukan!"}; | |||||
return result; | |||||
} | } | ||||
closeDb() async { | closeDb() async { | ||||
final database = await db; | |||||
await database.close(); | |||||
_db = null; | |||||
try{ | |||||
Database database = await db; | |||||
if(database.isOpen) await database.close(); | |||||
_db = null; | |||||
} | |||||
catch(e){ | |||||
_db = null; | |||||
} | |||||
} | } | ||||
_onCreate(Database db, int version) async { | _onCreate(Database db, int version) async { | ||||
@@ -266,9 +310,11 @@ class DBHelper { | |||||
try{ | try{ | ||||
final database = await db; | final database = await db; | ||||
var res = await database.query(tableName.values,where: "${columnName.name} = ?",whereArgs: [value]); | var res = await database.query(tableName.values,where: "${columnName.name} = ?",whereArgs: [value]); | ||||
var res2 = await database.query(tableName.values); | |||||
return res.isEmpty?null:valueTab.fromJson(res.first); | return res.isEmpty?null:valueTab.fromJson(res.first); | ||||
} | } | ||||
catch(e){ | catch(e){ | ||||
print(e); | |||||
return null; | return null; | ||||
} | } | ||||
} | } | ||||
@@ -307,7 +353,6 @@ class DBHelper { | |||||
newValue.name, | newValue.name, | ||||
newValue.value | newValue.value | ||||
]); | ]); | ||||
print('Row Inserted'); | |||||
return res; | return res; | ||||
} | } | ||||
catch(e){ | catch(e){ | ||||
@@ -12,6 +12,9 @@ class keyClass{ | |||||
static String targetProccess = 'dbPath'; | static String targetProccess = 'dbPath'; | ||||
static String submitProccess = 'SUBMIT'; | static String submitProccess = 'SUBMIT'; | ||||
static String stock_id = 'STOCK_TAKING_UNIT_ID'; | static String stock_id = 'STOCK_TAKING_UNIT_ID'; | ||||
static String backup_stock_id = 'BACKUP_STOCK_TAKING_UNIT_ID'; | |||||
static String backup_cabang_id = 'BACKUP_CABANG_ID'; | |||||
static String client_credential = 'CLIENT_CREDENTIAL'; | static String client_credential = 'CLIENT_CREDENTIAL'; | ||||
static String rest_data = 'REST_DATA'; | static String rest_data = 'REST_DATA'; | ||||
static String tgl_start = 'TGL_START'; | static String tgl_start = 'TGL_START'; | ||||
@@ -16,6 +16,7 @@ import 'package:intl/intl.dart'; | |||||
import 'main.dart'; | import 'main.dart'; | ||||
import 'Util/Prefs.dart'; | import 'Util/Prefs.dart'; | ||||
import 'Util/UnitModel.dart'; | import 'Util/UnitModel.dart'; | ||||
import 'package:permission_handler/permission_handler.dart' as pHandler; | |||||
class HomePage extends StatefulWidget { | class HomePage extends StatefulWidget { | ||||
// HomePage({Key key}) : super(key: key); | // HomePage({Key key}) : super(key: key); | ||||
@@ -36,7 +37,7 @@ class _HomePageState extends State<HomePage> { | |||||
String state = ''; | String state = ''; | ||||
final hostAddress = new TextEditingController(); | final hostAddress = new TextEditingController(); | ||||
clearData(context)async{ | |||||
clearData(context,{backup=true})async{ | |||||
setState(() { | setState(() { | ||||
progressDL = null; | progressDL = null; | ||||
isLoading = false; | isLoading = false; | ||||
@@ -56,40 +57,31 @@ class _HomePageState extends State<HomePage> { | |||||
onPressed: ()async{ | onPressed: ()async{ | ||||
util.showLoading(context); | util.showLoading(context); | ||||
await Future.sync(()async{ | await Future.sync(()async{ | ||||
await prefs.remove(keyClass.lastDownload); | |||||
await prefs.remove(keyClass.lastUpload); | |||||
await prefs.remove(keyClass.targetProccess); | |||||
await prefs.remove(keyClass.submitProccess); | |||||
await prefs.remove(keyClass.stock_id); | |||||
setState(() { | |||||
lastUpload = ''; | |||||
lastDownload = ''; | |||||
timeString = ''; | |||||
}); | |||||
// var result = await DBHelper.database.deleteAll(); | |||||
// if(result!=null) { | |||||
// await DBHelper.database.closeDb(); | |||||
// if(result!=null){ | |||||
try{ | try{ | ||||
Directory documentsDirectory = await getExternalStorageDirectory(); | Directory documentsDirectory = await getExternalStorageDirectory(); | ||||
String path = join(documentsDirectory.path, "UnitStocking.db"); | String path = join(documentsDirectory.path, "UnitStocking.db"); | ||||
File db = File(path); | File db = File(path); | ||||
if(db.existsSync()){ | if(db.existsSync()){ | ||||
await DBHelper.database.closeDb(); | |||||
//auto backup | |||||
// if(backup)await DBHelper.database.backupDb(context); | |||||
db.deleteSync(); | db.deleteSync(); | ||||
await prefs.remove(keyClass.lastDownload); | |||||
await prefs.remove(keyClass.lastUpload); | |||||
await prefs.remove(keyClass.targetProccess); | |||||
await prefs.remove(keyClass.submitProccess); | |||||
await prefs.remove(keyClass.stock_id); | |||||
setState(() { | |||||
lastUpload = ''; | |||||
lastDownload = ''; | |||||
timeString = ''; | |||||
}); | |||||
} | } | ||||
} | } | ||||
catch(e){ | catch(e){ | ||||
print(e); | print(e); | ||||
util.showFlushbar(context, 'Failed to delete database file',color: Colors.red); | util.showFlushbar(context, 'Failed to delete database file',color: Colors.red); | ||||
} | } | ||||
// } | |||||
// else{ | |||||
// errMsg = 'Failed to clear unit data'; | |||||
// } | |||||
// } | |||||
// else{ | |||||
// errMsg = 'Failed to clear unit data'; | |||||
// } | |||||
}); | }); | ||||
Navigator.pop(context); | Navigator.pop(context); | ||||
Navigator.pop(context,true); | Navigator.pop(context,true); | ||||
@@ -133,6 +125,7 @@ class _HomePageState extends State<HomePage> { | |||||
lastUpload = prefs.getString(keyClass.lastUpload)??''; | lastUpload = prefs.getString(keyClass.lastUpload)??''; | ||||
WidgetsBinding.instance.addPostFrameCallback((_) async { | WidgetsBinding.instance.addPostFrameCallback((_) async { | ||||
await _check_Update(); | await _check_Update(); | ||||
await util.permissionCheck(context,pHandler.Permission.storage,()async{print("storage permit granted!");},customMessage: " untuk menyimpan data backup"); | |||||
}); | }); | ||||
} | } | ||||
@@ -522,12 +515,22 @@ class _HomePageState extends State<HomePage> { | |||||
), | ), | ||||
), | ), | ||||
PopupMenuItem( | PopupMenuItem( | ||||
value:'backup', | |||||
child: Row( | |||||
children: <Widget>[ | |||||
Icon(Icons.save,color: Colors.black,), | |||||
SizedBox(width: 10,), | |||||
Text('Backup Data') | |||||
], | |||||
), | |||||
), | |||||
PopupMenuItem( | |||||
value:'restore', | value:'restore', | ||||
child: Row( | child: Row( | ||||
children: <Widget>[ | children: <Widget>[ | ||||
Icon(Icons.sync,color: Colors.black,), | Icon(Icons.sync,color: Colors.black,), | ||||
SizedBox(width: 10,), | SizedBox(width: 10,), | ||||
Text('Restore Backup') | |||||
Text('Restore Data') | |||||
], | ], | ||||
), | ), | ||||
), | ), | ||||
@@ -670,40 +673,71 @@ class _HomePageState extends State<HomePage> { | |||||
prefs.setBool(keyClass.logged_in, false); | prefs.setBool(keyClass.logged_in, false); | ||||
Navigator.pushNamed(context, '/login'); | Navigator.pushNamed(context, '/login'); | ||||
} | } | ||||
if(value == 'backup'){ | |||||
var result = await DBHelper.database.backupDb(); | |||||
util.showFlushbar(context, result['MSG'],color: result["STATUS"]==1?Colors.grey:Colors.red); | |||||
} | |||||
if(value == 'restore'){ | if(value == 'restore'){ | ||||
await showDialog(context: context,builder: (context)=>AlertDialog( | |||||
bool isRestore = await showDialog(context: context,builder: (context)=>AlertDialog( | |||||
title: Text('Restore Data ?'), | title: Text('Restore Data ?'), | ||||
content: Text('Restore data akan menghapus dan mengganti data unit yang ada dengan data unit backup.'), | |||||
content: Text('Restore data akan menghapus dan mengganti data unit dan cabang yang ada dengan data backup.'), | |||||
actions: <Widget>[ | actions: <Widget>[ | ||||
TextButton( | TextButton( | ||||
child: Text('Proceed'), | child: Text('Proceed'), | ||||
onPressed: ()async{ | onPressed: ()async{ | ||||
util.showLoading(context); | |||||
var result = await DBHelper.database.restoreDb(); | |||||
if(result["STATUS"]==1){ | |||||
await prefs.remove(keyClass.lastDownload); | |||||
await prefs.remove(keyClass.lastUpload); | |||||
await prefs.remove(keyClass.targetProccess); | |||||
await prefs.remove(keyClass.submitProccess); | |||||
setState(() { | |||||
lastUpload = ''; | |||||
lastDownload = ''; | |||||
timeString = ''; | |||||
}); | |||||
valueTab value = await DBHelper.database.getValue(keyClass.tgl_start); | |||||
if(value != null)await prefs.setString(keyClass.lastDownload, value.value); | |||||
} | |||||
util.showFlushbar(context, result["MSG"]); | |||||
Navigator.pop(context); | |||||
Navigator.pop(context); | |||||
Navigator.pop(context,true); | |||||
}, | }, | ||||
), | ), | ||||
TextButton( | TextButton( | ||||
child: Text('Cancel'), | child: Text('Cancel'), | ||||
onPressed: ()=>Navigator.pop(context), | |||||
onPressed: ()=>Navigator.pop(context,false), | |||||
) | ) | ||||
], | ], | ||||
)); | )); | ||||
if(isRestore??false){ | |||||
var response; | |||||
bool isclear; | |||||
Directory documentsDirectory = await getExternalStorageDirectory(); | |||||
String path = join(documentsDirectory.path, "UnitStocking.db"); | |||||
File db = File(path); | |||||
if(db.existsSync()){ | |||||
isclear = await clearData(context,backup: false); | |||||
} | |||||
else{ | |||||
isclear = true; | |||||
} | |||||
if(isclear??false){ | |||||
var result = await DBHelper.database.restoreDb(); | |||||
if(result["STATUS"]==1){ | |||||
await prefs.remove(keyClass.lastDownload); | |||||
await prefs.remove(keyClass.lastUpload); | |||||
await prefs.remove(keyClass.targetProccess); | |||||
await prefs.remove(keyClass.submitProccess); | |||||
setState(() { | |||||
lastUpload = ''; | |||||
lastDownload = ''; | |||||
timeString = ''; | |||||
}); | |||||
valueTab value = await DBHelper.database.getValue(keyClass.tgl_start); | |||||
if(value != null)await prefs.setString(keyClass.lastDownload, DateFormat('dd-MM-yyyy HH:mm:ss').parse(value.value).toIso8601String()); | |||||
else { | |||||
await prefs.setString(keyClass.lastDownload, DateTime.now().toIso8601String()); | |||||
} | |||||
value = await DBHelper.database.getValue(keyClass.stock_id); | |||||
if(value != null) await prefs.setString(keyClass.stock_id,value.value); | |||||
else { | |||||
await prefs.setString(keyClass.stock_id,prefs.getString(keyClass.backup_stock_id)); | |||||
} | |||||
await prefs.setString(keyClass.cabang_id,prefs.getString(keyClass.backup_cabang_id)); | |||||
loadState(); | |||||
setState(() { | |||||
lastDownload = prefs.getString(keyClass.lastDownload); | |||||
}); | |||||
} | |||||
response = result["MSG"]; | |||||
} | |||||
if(response != null)util.showFlushbar(context, response); | |||||
} | |||||
} | } | ||||
}, | }, | ||||
), | ), | ||||
@@ -803,9 +837,9 @@ class _HomePageState extends State<HomePage> { | |||||
lastDownload = DateTime.now().toIso8601String(); | lastDownload = DateTime.now().toIso8601String(); | ||||
}); | }); | ||||
await prefs.setString(keyClass.lastDownload, lastDownload); | await prefs.setString(keyClass.lastDownload, lastDownload); | ||||
await DBHelper.database.insertUpdateValue(new valueTab(name: 'TGL_START',value: DateFormat('dd-MM-yyyy HH:mm:ss').format(DateTime.parse(lastDownload)))); | |||||
await DBHelper.database.insertUpdateValue(new valueTab(name: 'TGL_STOCK_TAKING',value: DateFormat('dd-MM-yyyy').format(DateTime.parse(lastDownload)))); | |||||
await DBHelper.database.closeDb(); | await DBHelper.database.closeDb(); | ||||
await DBHelper.database.insertUpdateValue(new valueTab(name: keyClass.tgl_start,value: DateFormat('dd-MM-yyyy HH:mm:ss').format(DateTime.parse(lastDownload)))); | |||||
await DBHelper.database.insertUpdateValue(new valueTab(name: 'TGL_STOCK_TAKING',value: DateFormat('dd-MM-yyyy').format(DateTime.parse(lastDownload)))); | |||||
util.showFlushbar(context,'Data downloaded'); | util.showFlushbar(context,'Data downloaded'); | ||||
loadState(); | loadState(); | ||||
a.stop(); | a.stop(); | ||||
@@ -3,6 +3,7 @@ import 'package:flutter/cupertino.dart'; | |||||
import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||
import 'main.dart'; | import 'main.dart'; | ||||
import 'Util/Prefs.dart'; | import 'Util/Prefs.dart'; | ||||
import 'package:permission_handler/permission_handler.dart' as pHandler; | |||||
class LoginPage extends StatefulWidget { | class LoginPage extends StatefulWidget { | ||||
@@ -23,7 +24,7 @@ class _LoginPageState extends State<LoginPage> { | |||||
Login()async{ | Login()async{ | ||||
util.showLoading(context); | util.showLoading(context); | ||||
var result = await util.JsonDataPostRaw({"User":userCon.text,"Pass":passCon.text}, '${prefs.getString(keyClass.hostAddress)}/user//login/'); | var result = await util.JsonDataPostRaw({"User":userCon.text,"Pass":passCon.text}, '${prefs.getString(keyClass.hostAddress)}/user//login/'); | ||||
if(result['STATUS']==1){ | |||||
if(result['STATUS']==1&& result["DATA"]["status"]=='OK'){ | |||||
prefs.setString(keyClass.loginId, result['DATA'][keyClass.loginId.toLowerCase()]); | prefs.setString(keyClass.loginId, result['DATA'][keyClass.loginId.toLowerCase()]); | ||||
print("user id ${result['DATA'][keyClass.loginId.toLowerCase()]}"); | print("user id ${result['DATA'][keyClass.loginId.toLowerCase()]}"); | ||||
prefs.setString(keyClass.company, result['DATA'][keyClass.company.toLowerCase()]); | prefs.setString(keyClass.company, result['DATA'][keyClass.company.toLowerCase()]); | ||||
@@ -43,10 +44,17 @@ class _LoginPageState extends State<LoginPage> { | |||||
} | } | ||||
else{ | else{ | ||||
Navigator.pop(context); | Navigator.pop(context); | ||||
util.showFlushbar(context, result['DATA'],color: Colors.red); | |||||
print(result is String); | |||||
util.showFlushbar(context, (result['DATA'] is String)?result['DATA']:result['DATA']['info'],color: Colors.red); | |||||
} | } | ||||
} | } | ||||
@override | |||||
void initState() { | |||||
WidgetsBinding.instance.addPostFrameCallback((_) async { | |||||
await util.permissionCheck(context,pHandler.Permission.storage,()async{print("storage permit granted!");},customMessage: " untuk menyimpan data backup"); | |||||
}); | |||||
super.initState(); | |||||
} | |||||
@override | @override | ||||
Widget build(BuildContext context) { | Widget build(BuildContext context) { | ||||
// if(prefs.getBool(keyClass.logged_in)==null||!prefs.getBool(keyClass.logged_in)){ | // if(prefs.getBool(keyClass.logged_in)==null||!prefs.getBool(keyClass.logged_in)){ | ||||
@@ -11,7 +11,6 @@ import 'unit_details.dart'; | |||||
import 'package:shared_preferences/shared_preferences.dart'; | import 'package:shared_preferences/shared_preferences.dart'; | ||||
import 'package:location/location.dart'; | import 'package:location/location.dart'; | ||||
import 'Util/Util.dart'; | import 'Util/Util.dart'; | ||||
import 'package:flutter_logs/flutter_logs.dart'; | |||||
SharedPreferences prefs; | SharedPreferences prefs; | ||||
@@ -56,6 +55,7 @@ void main() async{ | |||||
// logsExportDirectoryName: "MyLogs/Exported", | // logsExportDirectoryName: "MyLogs/Exported", | ||||
// debugFileOperations: true, | // debugFileOperations: true, | ||||
// isDebuggable: true); | // isDebuggable: true); | ||||
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]) | SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]) | ||||
.then((_) { | .then((_) { | ||||
runApp(new MyApp()); | runApp(new MyApp()); | ||||
@@ -198,7 +198,39 @@ class _StockingState extends State<Stocking> with SingleTickerProviderStateMixin | |||||
child:Stack( | child:Stack( | ||||
children: <Widget>[ | children: <Widget>[ | ||||
Container( | Container( | ||||
child: ListView.builder( | |||||
alignment: Alignment.topRight, | |||||
child: (unitsRef.isEmpty) | |||||
? Container(padding: EdgeInsets.only(top: 10,left: 10,right: 10), | |||||
child: Row( | |||||
crossAxisAlignment: CrossAxisAlignment.start, | |||||
mainAxisAlignment: MainAxisAlignment.spaceBetween, | |||||
children: <Widget>[ | |||||
Row( | |||||
children: <Widget>[ | |||||
Checkbox( | |||||
value: completed, | |||||
onChanged: (value)async{ | |||||
setState(() { | |||||
completed = value; | |||||
}); | |||||
await loadUnit(); | |||||
}, | |||||
), | |||||
Text('Completed') | |||||
], | |||||
), | |||||
(completed||hideAppbar)?Container():Row( | |||||
mainAxisAlignment: MainAxisAlignment.end, | |||||
children: <Widget>[ | |||||
Text('Unit : ',style: TextStyle(color: Colors.grey,fontSize: 15),), | |||||
Text('${(unitsRef.where((element) => element.flag=='TRUE').length==unitsRef.length)?'Done':'${unitsRef.length-unitsRef.where((element) => element.flag=='TRUE').length}'}',style: TextStyle(color: (unitsRef.length==unitsRef.where((element) => element.flag=='TRUE').length)?Colors.green:Colors.black,fontWeight: FontWeight.bold,fontSize: 16),), | |||||
Text(!(unitsRef.length==unitsRef.where((element) => element.flag=='TRUE').length)?' of':'',style: TextStyle(color: Colors.grey,fontSize: 15),), | |||||
Text(!(unitsRef.length==unitsRef.where((element) => element.flag=='TRUE').length)?' ${unitsRef.length}':'',style: TextStyle(color: Colors.black,fontSize: 16,fontWeight: FontWeight.bold,),), | |||||
], | |||||
), | |||||
], | |||||
),) | |||||
:ListView.builder( | |||||
padding: EdgeInsets.only(bottom: 10), | padding: EdgeInsets.only(bottom: 10), | ||||
itemCount: unitsRef.length, | itemCount: unitsRef.length, | ||||
shrinkWrap: false, | shrinkWrap: false, | ||||
@@ -7,7 +7,7 @@ packages: | |||||
name: archive | name: archive | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "3.1.5" | |||||
version: "3.2.1" | |||||
args: | args: | ||||
dependency: transitive | dependency: transitive | ||||
description: | description: | ||||
@@ -21,14 +21,14 @@ packages: | |||||
name: async | name: async | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "2.8.1" | |||||
version: "2.8.2" | |||||
barcode_scan2: | barcode_scan2: | ||||
dependency: "direct main" | dependency: "direct main" | ||||
description: | description: | ||||
name: barcode_scan2 | name: barcode_scan2 | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "4.1.4" | |||||
version: "4.2.0" | |||||
boolean_selector: | boolean_selector: | ||||
dependency: transitive | dependency: transitive | ||||
description: | description: | ||||
@@ -42,7 +42,7 @@ packages: | |||||
name: characters | name: characters | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "1.1.0" | |||||
version: "1.2.0" | |||||
charcode: | charcode: | ||||
dependency: transitive | dependency: transitive | ||||
description: | description: | ||||
@@ -70,7 +70,7 @@ packages: | |||||
name: cross_file | name: cross_file | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "0.3.1+5" | |||||
version: "0.3.2" | |||||
crypto: | crypto: | ||||
dependency: transitive | dependency: transitive | ||||
description: | description: | ||||
@@ -84,7 +84,7 @@ packages: | |||||
name: cupertino_icons | name: cupertino_icons | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "0.1.3" | |||||
version: "1.0.4" | |||||
fake_async: | fake_async: | ||||
dependency: transitive | dependency: transitive | ||||
description: | description: | ||||
@@ -138,14 +138,14 @@ packages: | |||||
name: flutter_logs | name: flutter_logs | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "2.1.4" | |||||
version: "2.1.5" | |||||
flutter_plugin_android_lifecycle: | flutter_plugin_android_lifecycle: | ||||
dependency: transitive | dependency: transitive | ||||
description: | description: | ||||
name: flutter_plugin_android_lifecycle | name: flutter_plugin_android_lifecycle | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "2.0.3" | |||||
version: "2.0.5" | |||||
flutter_test: | flutter_test: | ||||
dependency: "direct dev" | dependency: "direct dev" | ||||
description: flutter | description: flutter | ||||
@@ -176,35 +176,35 @@ packages: | |||||
name: image | name: image | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "3.0.8" | |||||
version: "3.1.3" | |||||
image_picker: | image_picker: | ||||
dependency: "direct main" | dependency: "direct main" | ||||
description: | description: | ||||
name: image_picker | name: image_picker | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "0.8.4+4" | |||||
version: "0.8.4+9" | |||||
image_picker_for_web: | image_picker_for_web: | ||||
dependency: transitive | dependency: transitive | ||||
description: | description: | ||||
name: image_picker_for_web | name: image_picker_for_web | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "2.1.3" | |||||
version: "2.1.6" | |||||
image_picker_platform_interface: | image_picker_platform_interface: | ||||
dependency: transitive | dependency: transitive | ||||
description: | description: | ||||
name: image_picker_platform_interface | name: image_picker_platform_interface | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "2.4.1" | |||||
version: "2.4.4" | |||||
in_app_update: | in_app_update: | ||||
dependency: "direct main" | dependency: "direct main" | ||||
description: | description: | ||||
name: in_app_update | name: in_app_update | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "2.0.0" | |||||
version: "3.0.0" | |||||
intl: | intl: | ||||
dependency: "direct main" | dependency: "direct main" | ||||
description: | description: | ||||
@@ -246,7 +246,7 @@ packages: | |||||
name: matcher | name: matcher | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "0.12.10" | |||||
version: "0.12.11" | |||||
meta: | meta: | ||||
dependency: transitive | dependency: transitive | ||||
description: | description: | ||||
@@ -281,14 +281,14 @@ packages: | |||||
name: path_provider | name: path_provider | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "2.0.7" | |||||
version: "2.0.9" | |||||
path_provider_android: | path_provider_android: | ||||
dependency: transitive | dependency: transitive | ||||
description: | description: | ||||
name: path_provider_android | name: path_provider_android | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "2.0.9" | |||||
version: "2.0.11" | |||||
path_provider_ios: | path_provider_ios: | ||||
dependency: transitive | dependency: transitive | ||||
description: | description: | ||||
@@ -302,35 +302,49 @@ packages: | |||||
name: path_provider_linux | name: path_provider_linux | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "2.1.0" | |||||
version: "2.1.5" | |||||
path_provider_macos: | path_provider_macos: | ||||
dependency: transitive | dependency: transitive | ||||
description: | description: | ||||
name: path_provider_macos | name: path_provider_macos | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "2.0.2" | |||||
version: "2.0.5" | |||||
path_provider_platform_interface: | path_provider_platform_interface: | ||||
dependency: transitive | dependency: transitive | ||||
description: | description: | ||||
name: path_provider_platform_interface | name: path_provider_platform_interface | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "2.0.1" | |||||
version: "2.0.3" | |||||
path_provider_windows: | path_provider_windows: | ||||
dependency: transitive | dependency: transitive | ||||
description: | description: | ||||
name: path_provider_windows | name: path_provider_windows | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "2.0.3" | |||||
version: "2.0.5" | |||||
permission_handler: | permission_handler: | ||||
dependency: "direct main" | dependency: "direct main" | ||||
description: | description: | ||||
name: permission_handler | name: permission_handler | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "8.3.0" | |||||
version: "9.2.0" | |||||
permission_handler_android: | |||||
dependency: transitive | |||||
description: | |||||
name: permission_handler_android | |||||
url: "https://pub.dartlang.org" | |||||
source: hosted | |||||
version: "9.0.2" | |||||
permission_handler_apple: | |||||
dependency: transitive | |||||
description: | |||||
name: permission_handler_apple | |||||
url: "https://pub.dartlang.org" | |||||
source: hosted | |||||
version: "9.0.2" | |||||
permission_handler_platform_interface: | permission_handler_platform_interface: | ||||
dependency: transitive | dependency: transitive | ||||
description: | description: | ||||
@@ -338,13 +352,20 @@ packages: | |||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "3.7.0" | version: "3.7.0" | ||||
permission_handler_windows: | |||||
dependency: transitive | |||||
description: | |||||
name: permission_handler_windows | |||||
url: "https://pub.dartlang.org" | |||||
source: hosted | |||||
version: "0.1.0" | |||||
petitparser: | petitparser: | ||||
dependency: transitive | dependency: transitive | ||||
description: | description: | ||||
name: petitparser | name: petitparser | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "4.3.0" | |||||
version: "4.4.0" | |||||
photo_view: | photo_view: | ||||
dependency: "direct main" | dependency: "direct main" | ||||
description: | description: | ||||
@@ -358,21 +379,21 @@ packages: | |||||
name: platform | name: platform | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "3.0.2" | |||||
version: "3.1.0" | |||||
plugin_platform_interface: | plugin_platform_interface: | ||||
dependency: transitive | dependency: transitive | ||||
description: | description: | ||||
name: plugin_platform_interface | name: plugin_platform_interface | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "2.0.2" | |||||
version: "2.1.2" | |||||
process: | process: | ||||
dependency: transitive | dependency: transitive | ||||
description: | description: | ||||
name: process | name: process | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "4.2.3" | |||||
version: "4.2.4" | |||||
protobuf: | protobuf: | ||||
dependency: transitive | dependency: transitive | ||||
description: | description: | ||||
@@ -386,35 +407,35 @@ packages: | |||||
name: shared_preferences | name: shared_preferences | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "2.0.9" | |||||
version: "2.0.13" | |||||
shared_preferences_android: | shared_preferences_android: | ||||
dependency: transitive | dependency: transitive | ||||
description: | description: | ||||
name: shared_preferences_android | name: shared_preferences_android | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "2.0.9" | |||||
version: "2.0.11" | |||||
shared_preferences_ios: | shared_preferences_ios: | ||||
dependency: transitive | dependency: transitive | ||||
description: | description: | ||||
name: shared_preferences_ios | name: shared_preferences_ios | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "2.0.8" | |||||
version: "2.1.0" | |||||
shared_preferences_linux: | shared_preferences_linux: | ||||
dependency: transitive | dependency: transitive | ||||
description: | description: | ||||
name: shared_preferences_linux | name: shared_preferences_linux | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "2.0.2" | |||||
version: "2.1.0" | |||||
shared_preferences_macos: | shared_preferences_macos: | ||||
dependency: transitive | dependency: transitive | ||||
description: | description: | ||||
name: shared_preferences_macos | name: shared_preferences_macos | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "2.0.2" | |||||
version: "2.0.3" | |||||
shared_preferences_platform_interface: | shared_preferences_platform_interface: | ||||
dependency: transitive | dependency: transitive | ||||
description: | description: | ||||
@@ -428,14 +449,14 @@ packages: | |||||
name: shared_preferences_web | name: shared_preferences_web | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "2.0.2" | |||||
version: "2.0.3" | |||||
shared_preferences_windows: | shared_preferences_windows: | ||||
dependency: transitive | dependency: transitive | ||||
description: | description: | ||||
name: shared_preferences_windows | name: shared_preferences_windows | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "2.0.2" | |||||
version: "2.1.0" | |||||
sky_engine: | sky_engine: | ||||
dependency: transitive | dependency: transitive | ||||
description: flutter | description: flutter | ||||
@@ -454,14 +475,14 @@ packages: | |||||
name: sqflite | name: sqflite | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "2.0.0+4" | |||||
version: "2.0.2" | |||||
sqflite_common: | sqflite_common: | ||||
dependency: transitive | dependency: transitive | ||||
description: | description: | ||||
name: sqflite_common | name: sqflite_common | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "2.0.1+1" | |||||
version: "2.2.0" | |||||
stack_trace: | stack_trace: | ||||
dependency: transitive | dependency: transitive | ||||
description: | description: | ||||
@@ -503,7 +524,7 @@ packages: | |||||
name: test_api | name: test_api | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "0.4.2" | |||||
version: "0.4.3" | |||||
typed_data: | typed_data: | ||||
dependency: transitive | dependency: transitive | ||||
description: | description: | ||||
@@ -517,84 +538,84 @@ packages: | |||||
name: url_launcher | name: url_launcher | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "6.0.17" | |||||
version: "6.0.20" | |||||
url_launcher_android: | url_launcher_android: | ||||
dependency: transitive | dependency: transitive | ||||
description: | description: | ||||
name: url_launcher_android | name: url_launcher_android | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "6.0.13" | |||||
version: "6.0.15" | |||||
url_launcher_ios: | url_launcher_ios: | ||||
dependency: transitive | dependency: transitive | ||||
description: | description: | ||||
name: url_launcher_ios | name: url_launcher_ios | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "6.0.13" | |||||
version: "6.0.15" | |||||
url_launcher_linux: | url_launcher_linux: | ||||
dependency: transitive | dependency: transitive | ||||
description: | description: | ||||
name: url_launcher_linux | name: url_launcher_linux | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "2.0.2" | |||||
version: "3.0.0" | |||||
url_launcher_macos: | url_launcher_macos: | ||||
dependency: transitive | dependency: transitive | ||||
description: | description: | ||||
name: url_launcher_macos | name: url_launcher_macos | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "2.0.2" | |||||
version: "3.0.0" | |||||
url_launcher_platform_interface: | url_launcher_platform_interface: | ||||
dependency: transitive | dependency: transitive | ||||
description: | description: | ||||
name: url_launcher_platform_interface | name: url_launcher_platform_interface | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "2.0.4" | |||||
version: "2.0.5" | |||||
url_launcher_web: | url_launcher_web: | ||||
dependency: transitive | dependency: transitive | ||||
description: | description: | ||||
name: url_launcher_web | name: url_launcher_web | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "2.0.5" | |||||
version: "2.0.6" | |||||
url_launcher_windows: | url_launcher_windows: | ||||
dependency: transitive | dependency: transitive | ||||
description: | description: | ||||
name: url_launcher_windows | name: url_launcher_windows | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "2.0.2" | |||||
version: "3.0.0" | |||||
vector_math: | vector_math: | ||||
dependency: transitive | dependency: transitive | ||||
description: | description: | ||||
name: vector_math | name: vector_math | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "2.1.0" | |||||
version: "2.1.1" | |||||
win32: | win32: | ||||
dependency: transitive | dependency: transitive | ||||
description: | description: | ||||
name: win32 | name: win32 | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "2.2.9" | |||||
version: "2.4.1" | |||||
xdg_directories: | xdg_directories: | ||||
dependency: transitive | dependency: transitive | ||||
description: | description: | ||||
name: xdg_directories | name: xdg_directories | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "0.2.0" | |||||
version: "0.2.0+1" | |||||
xml: | xml: | ||||
dependency: transitive | dependency: transitive | ||||
description: | description: | ||||
name: xml | name: xml | ||||
url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
source: hosted | source: hosted | ||||
version: "5.3.0" | |||||
version: "5.3.1" | |||||
yaml: | yaml: | ||||
dependency: transitive | dependency: transitive | ||||
description: | description: | ||||
@@ -603,5 +624,5 @@ packages: | |||||
source: hosted | source: hosted | ||||
version: "3.1.0" | version: "3.1.0" | ||||
sdks: | sdks: | ||||
dart: ">=2.14.0 <3.0.0" | |||||
flutter: ">=2.5.0" | |||||
dart: ">=2.15.0 <3.0.0" | |||||
flutter: ">=2.8.0" |
@@ -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.4+8 | |||||
version: 1.0.5+9 | |||||
environment: | environment: | ||||
sdk: ">=2.1.0 <3.0.0" | sdk: ">=2.1.0 <3.0.0" | ||||
@@ -13,23 +13,23 @@ dependencies: | |||||
# The following adds the Cupertino Icons font to your application. | # The following adds the Cupertino Icons font to your application. | ||||
# Use with the CupertinoIcons class for iOS style icons. | # Use with the CupertinoIcons class for iOS style icons. | ||||
cupertino_icons: | cupertino_icons: | ||||
image_picker: ^0.8.4+4 | |||||
image_picker: ^0.8.4+9 | |||||
photo_view: ^0.13.0 | photo_view: ^0.13.0 | ||||
sqflite: ^2.0.0+4 | |||||
path_provider: ^2.0.7 | |||||
sqflite: ^2.0.2 | |||||
path_provider: ^2.0.9 | |||||
flushbar: ^1.10.4 | flushbar: ^1.10.4 | ||||
http: ^0.13.4 | http: ^0.13.4 | ||||
intl: ^0.17.0 | intl: ^0.17.0 | ||||
shared_preferences: ^2.0.9 | |||||
shared_preferences: ^2.0.13 | |||||
location: ^4.3.0 | location: ^4.3.0 | ||||
# path: 'local_plugin/location-3.0.2' | # path: 'local_plugin/location-3.0.2' | ||||
permission_handler: ^8.3.0 | |||||
permission_handler: ^9.2.0 | |||||
# app_settings: | # app_settings: | ||||
# autocomplete_textfield: | # autocomplete_textfield: | ||||
barcode_scan2: ^4.1.4 | |||||
barcode_scan2: ^4.2.0 | |||||
oauth2: ^2.0.0 | oauth2: ^2.0.0 | ||||
in_app_update: ^2.0.0 | |||||
url_launcher: ^6.0.17 | |||||
in_app_update: ^3.0.0 | |||||
url_launcher: ^6.0.20 | |||||
package_info: ^2.0.2 | package_info: ^2.0.2 | ||||