mirror of
https://github.com/alibaba/flutter-go.git
synced 2025-05-17 12:55:57 +08:00
fix bug:android emulator
This commit is contained in:
@ -6,6 +6,8 @@
|
||||
to allow setting breakpoints, to provide hot reload, etc.
|
||||
-->
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.MODE_WORLD_READABLE"/>
|
||||
<uses-permission android:name="android.permission.MODE_WORLD_WRITEABLE"/>
|
||||
|
||||
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
|
||||
calls FlutterMain.startInitialization(this); in its onCreate method.
|
||||
|
BIN
assets/app.db
BIN
assets/app.db
Binary file not shown.
@ -11,27 +11,38 @@ class Provider {
|
||||
//初始化数据库
|
||||
// isCreate 用永远 copy 一个新的数据库
|
||||
Future init(bool isCreate) async {
|
||||
//Get a location using getDatabasesPath
|
||||
String databasesPath = await getDatabasesPath();
|
||||
String path = join(databasesPath, 'flutter.db');
|
||||
try {
|
||||
db = await openDatabase(path);
|
||||
} catch (e) {
|
||||
print("Error $e");
|
||||
}
|
||||
if (isCreate) {
|
||||
List<Map> list;
|
||||
// try {
|
||||
// db = await openDatabase(path, readOnly: true);
|
||||
|
||||
// } catch (e) {
|
||||
// print("Error $e");
|
||||
// }
|
||||
|
||||
if (db == null) {
|
||||
// Delete the database
|
||||
await deleteDatabase(path);
|
||||
|
||||
ByteData data = await rootBundle.load(join("assets", "app.db"));
|
||||
List<int> bytes =
|
||||
data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes);
|
||||
await new File(path).writeAsBytes(bytes);
|
||||
|
||||
db = await openDatabase(path, version: 2,
|
||||
onCreate: (Database db, int version) async {
|
||||
print('db created version is $version');
|
||||
}, onOpen: (Database db) async {
|
||||
print('new db opened');
|
||||
});
|
||||
// db = await openDatabase(path, version: 2,
|
||||
// onCreate: (Database db, int version) async {
|
||||
// print('db created version is $version');
|
||||
// }, onOpen: (Database db) async {
|
||||
// print('new db opened');
|
||||
// });
|
||||
db = await openDatabase(path, readOnly: true);
|
||||
list = await db
|
||||
.rawQuery('SELECT name FROM sqlite_master WHERE type = "table"');
|
||||
print('$list 1234567891');
|
||||
} else {
|
||||
// print('Opening existing database');
|
||||
print("Opening existing database");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ class _CateCardState extends State<CateCard> {
|
||||
Cat childCateCondition = new Cat(parentId: parentId);
|
||||
|
||||
List<Cat> list = await catControl.getList(childCateCondition);
|
||||
if (list.isNotEmpty&&list.length>=1) {
|
||||
if (list.isNotEmpty&&list.length>=1 && this.mounted) {
|
||||
setState(() {
|
||||
_firstChildList = list;
|
||||
});
|
||||
|
@ -47,6 +47,7 @@ flutter:
|
||||
assets:
|
||||
- assets/app.db
|
||||
- assets/images/
|
||||
|
||||
# To add assets to your application, add an assets section, like this:
|
||||
# assets:
|
||||
# - images/a_dot_burr.jpeg
|
||||
|
Reference in New Issue
Block a user