jefry преди 3 години
родител
ревизия
497d1c83f1
променени са 5 файла, в които са добавени 38 реда и са изтрити 30 реда
  1. +3
    -2
      lib/Util/DBHelper.dart
  2. +5
    -5
      lib/Util/download_Upload_Handler.dart
  3. +4
    -4
      lib/home_page.dart
  4. +25
    -18
      lib/main.dart
  5. +1
    -1
      pubspec.yaml

+ 3
- 2
lib/Util/DBHelper.dart Целия файл

@@ -20,8 +20,9 @@ class DBHelper {
}

initDb() async {
io.Directory documentsDirectory = await getApplicationDocumentsDirectory();
io.Directory documentsDirectory = await getExternalStorageDirectory();
String path = join(documentsDirectory.path, "UnitStocking.db");
print("save at $path");
var theDb = await openDatabase(path, version: 1,onCreate: await _onCreate);
return theDb;
}
@@ -33,7 +34,7 @@ class DBHelper {
}

_onCreate(Database db, int version) async {
io.Directory documentsDirectory = await getApplicationDocumentsDirectory();
io.Directory documentsDirectory = await getExternalStorageDirectory();
String path = join(documentsDirectory.path, "UnitStocking.db");
io.File file = io.File(path);
print('Database created, ${file.lengthSync()}');


+ 5
- 5
lib/Util/download_Upload_Handler.dart Целия файл

@@ -73,7 +73,7 @@ class file_Trans_Handler {
_progress.add(0.0);
print('Finish Download');
final file = File(
"${(await getApplicationDocumentsDirectory()).path}/$fileName");
"${(await getExternalStorageDirectory()).path}/$fileName");
await file.writeAsBytes(_bytes);
_path = file.path;
}
@@ -114,7 +114,7 @@ class file_Trans_Handler {
httpClient = await util.getOauth2Client();
oauth2.Credentials tokenRestData = oauth2.Credentials.fromJson(prefs.getString(keyClass.rest_data));
final file = File(
"${(await getApplicationDocumentsDirectory()).path}/$fileName");
"${(await getExternalStorageDirectory()).path}/$fileName");
String mimeType = 'application/vnd.sqlite3';
if(file.existsSync()){
Uint8List byte = file.readAsBytesSync();
@@ -219,11 +219,11 @@ class file_Trans_Handler {
request.files.add(
await MultipartFile.fromPath(
'picture',
"${(await getApplicationDocumentsDirectory()).path}/$fileName"
"${(await getExternalStorageDirectory()).path}/$fileName"
)
);
_response = await httpClient.send(request);
_total = File("${(await getApplicationDocumentsDirectory()).path}/$fileName").lengthSync();
_total = File("${(await getExternalStorageDirectory()).path}/$fileName").lengthSync();
dlulStream = _response.stream.listen((value) {
_bytes.addAll(value);
print('upload ${_bytes.length/_total}');
@@ -233,7 +233,7 @@ class file_Trans_Handler {
_progress.add(0.0);
print('Finish Download');
final file = File(
"${(await getApplicationDocumentsDirectory()).path}/$fileName");
"${(await getExternalStorageDirectory()).path}/$fileName");
await file.writeAsBytes(_bytes);
_path = file.path;
})


+ 4
- 4
lib/home_page.dart Целия файл

@@ -71,7 +71,7 @@ class _HomePageState extends State<HomePage> {
// await DBHelper.database.closeDb();
// if(result!=null){
try{
Directory documentsDirectory = await getApplicationDocumentsDirectory();
Directory documentsDirectory = await getExternalStorageDirectory();
String path = join(documentsDirectory.path, "UnitStocking.db");
File db = File(path);
if(db.existsSync()){
@@ -292,7 +292,7 @@ class _HomePageState extends State<HomePage> {
lastDownload = '';
timeString = '';
try{
Directory documentsDirectory = await getApplicationDocumentsDirectory();
Directory documentsDirectory = await getExternalStorageDirectory();
String path = join(documentsDirectory.path, "UnitStocking.db");
File db = File(path);
if(db.existsSync()){
@@ -355,7 +355,7 @@ class _HomePageState extends State<HomePage> {
//// await DBHelper.database.closeDb();
//// if(result!=null){
// try{
// Directory documentsDirectory = await getApplicationDocumentsDirectory();
// Directory documentsDirectory = await getExternalStorageDirectory();
// String path = join(documentsDirectory.path, "UnitStocking.db");
// File db = File(path);
// if(db.existsSync()){
@@ -728,7 +728,7 @@ class _HomePageState extends State<HomePage> {
a.start();
await Future.delayed(Duration(milliseconds: 200));
bool isclear;
Directory documentsDirectory = await getApplicationDocumentsDirectory();
Directory documentsDirectory = await getExternalStorageDirectory();
String path = join(documentsDirectory.path, "UnitStocking.db");
File db = File(path);
if(db.existsSync()){


+ 25
- 18
lib/main.dart Целия файл

@@ -29,26 +29,33 @@ registerCert()async{
}

void main() async{
// prefs = await SharedPreferences.getInstance();
WidgetsFlutterBinding.ensureInitialized();
prefs = await SharedPreferences.getInstance();
SharedPreferences.getInstance().then((pref) async{
prefs = pref;
await prefs.setString(keyClass.hostAddress, "https://tbg.thamringroup.web.id/ords/tbs/unit/v1");
await prefs.setString(keyClass.restTokenAddress, "https://tbg.thamringroup.web.id/ords/tbs/oauth/token");
},
onError: (error) {
print("SharedPreferences ERROR = $error");
});
// if( prefs.getString(keyClass.hostAddress) ==null)
await registerCert();
if( prefs.getString(keyClass.hostAddress) ==null)await prefs.setString(keyClass.hostAddress, "https://tbg.thamringroup.web.id/ords/tbs/unit/v1");
await prefs.setString(keyClass.restTokenAddress, "https://tbg.thamringroup.web.id/ords/tbs/oauth/token");
await FlutterLogs.initLogs(
logLevelsEnabled: [
LogLevel.INFO,
LogLevel.WARNING,
LogLevel.ERROR,
LogLevel.SEVERE
],
timeStampFormat: TimeStampFormat.TIME_FORMAT_READABLE,
directoryStructure: DirectoryStructure.FOR_DATE,
logTypesEnabled: ["device","network","errors"],
logFileExtension: LogFileExtension.LOG,
logsWriteDirectoryName: "MyLogs",
logsExportDirectoryName: "MyLogs/Exported",
debugFileOperations: true,
isDebuggable: true);
// await FlutterLogs.initLogs(
// logLevelsEnabled: [
// LogLevel.INFO,
// LogLevel.WARNING,
// LogLevel.ERROR,
// LogLevel.SEVERE
// ],
// timeStampFormat: TimeStampFormat.TIME_FORMAT_READABLE,
// directoryStructure: DirectoryStructure.FOR_DATE,
// logTypesEnabled: ["device","network","errors"],
// logFileExtension: LogFileExtension.LOG,
// logsWriteDirectoryName: "MyLogs",
// logsExportDirectoryName: "MyLogs/Exported",
// debugFileOperations: true,
// isDebuggable: true);
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp])
.then((_) {
runApp(new MyApp());


+ 1
- 1
pubspec.yaml Целия файл

@@ -1,7 +1,7 @@
name: unitstocks
description: App to stock Thamrin Brothers Units
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.4+7
version: 1.0.4+8

environment:
sdk: ">=2.1.0 <3.0.0"


Зареждане…
Отказ
Запис