-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.dart
106 lines (100 loc) · 2.89 KB
/
main.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import 'package:example/tables.dart';
import 'package:flutter/material.dart';
import 'package:sqlite_at_runtime/sqlite_at_runtime.dart';
import 'package:toast/toast.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Runtime_SQLite Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
create() {
return Sqlartime.addNewDB('myDeeBee', 'optional');
}
delete() {
return Sqlartime.deleteDb(1, 'myDeeBee');
}
static Future<List<Map>> fetch() {
return Sqlartime.fetchDBs();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Container(
height: 400.0,
width: MediaQuery.of(context).size.width,
child: GridView.count(
crossAxisCount: 2,
childAspectRatio: 2.0,
padding: const EdgeInsets.all(8.0),
mainAxisSpacing: 12.0,
crossAxisSpacing: 12.0,
children: <Widget>[
RaisedButton(
child: Text(
'Create DB',
style: TextStyle(
fontSize: 28,
color: Colors.black,
),
textAlign: TextAlign.center,
),
onPressed: create,
),
RaisedButton(
child: Text(
'Drop DB',
style: TextStyle(
fontSize: 28,
color: Colors.black,
),
textAlign: TextAlign.center,
),
onPressed: delete,
),
RaisedButton(
child: Text(
'DB Detail',
style: TextStyle(
fontSize: 28,
color: Colors.black,
),
textAlign: TextAlign.center,
),
onPressed: () => fetch().then((value) {
Toast.show(value.toString(), context,
duration: Toast.LENGTH_LONG, gravity: Toast.BOTTOM);
}),
// onPressed:() {},
),
RaisedButton(
child: Text(
'Tables',
style: TextStyle(
fontSize: 28,
color: Colors.black,
),
textAlign: TextAlign.center,
),
onPressed: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) => Tables()));
},
),
],
),
),
),
);
}
}