Adds db helper requsts for flights pertaining to drones/batteries, and config class with generated json serializer
This commit is contained in:
@ -11,19 +11,19 @@ import 'package:image_picker/image_picker.dart';
|
||||
import 'package:sqlite3_flutter_libs/sqlite3_flutter_libs.dart';
|
||||
|
||||
void main() {
|
||||
if(Platform.isWindows || Platform.isLinux)
|
||||
{
|
||||
sqfliteFfiInit();
|
||||
databaseFactory = databaseFactoryFfi;
|
||||
}
|
||||
if (Platform.isWindows || Platform.isLinux) {
|
||||
sqfliteFfiInit();
|
||||
databaseFactory = databaseFactoryFfi;
|
||||
}
|
||||
|
||||
Logger.root.level = Level.ALL;
|
||||
Logger.root.onRecord.listen((record) =>
|
||||
print('${record.level.name}: ${record.time}: ${record.message}')
|
||||
);
|
||||
Logger.root.level = Level.ALL;
|
||||
Logger.root.onRecord.listen(
|
||||
(record) =>
|
||||
print('${record.level.name}: ${record.time}: ${record.message}'),
|
||||
);
|
||||
runApp(const MyApp());
|
||||
|
||||
//DbHelper.instance.closeDb();
|
||||
//DbHelper.instance.closeDb();
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
@ -79,14 +79,12 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
int _counter = 0;
|
||||
|
||||
Future _incrementCounter() async {
|
||||
|
||||
DbHelper.instance.insertDrone(Drone
|
||||
(
|
||||
name: "Image test",
|
||||
imageUuid: await ImagesManager.instance.createImage(ImageSource.camera)
|
||||
));
|
||||
|
||||
|
||||
DbHelper.instance.insertDrone(
|
||||
Drone(
|
||||
name: "Image test",
|
||||
imageUuid: await ImagesManager.instance.createImage(ImageSource.camera),
|
||||
),
|
||||
);
|
||||
|
||||
setState(() {
|
||||
// This call to setState tells the Flutter framework that something has
|
||||
@ -106,42 +104,36 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
// The Flutter framework has been optimized to make rerunning build methods
|
||||
// fast, so that you can just rebuild anything that needs updating rather
|
||||
// than having to individually change instances of widgets.
|
||||
var children =
|
||||
<Widget>[
|
||||
const Text('You have pushed the button this many times:'),
|
||||
Text(
|
||||
'$_counter',
|
||||
style: Theme.of(context).textTheme.headlineMedium,
|
||||
),
|
||||
FutureBuilder(
|
||||
future: Future<Widget>(() async
|
||||
{
|
||||
final drones = await DbHelper.instance.getDrones();
|
||||
var children = <Widget>[
|
||||
const Text('You have pushed the button this many times:'),
|
||||
Text('$_counter', style: Theme.of(context).textTheme.headlineMedium),
|
||||
FutureBuilder(
|
||||
future: Future<Widget>(() async {
|
||||
final drones = await DbHelper.instance.getDrones();
|
||||
|
||||
if(drones.isEmpty)
|
||||
{
|
||||
return Icon(Icons.question_mark);
|
||||
}
|
||||
if (drones.isEmpty) {
|
||||
return Icon(Icons.question_mark);
|
||||
}
|
||||
|
||||
final image = await ImagesManager.instance.loadImage(drones.first.imageUuid!);
|
||||
if(image == null)
|
||||
{
|
||||
return Icon(Icons.error);
|
||||
}
|
||||
final image = await ImagesManager.instance.loadImage(
|
||||
drones.first.imageUuid!,
|
||||
);
|
||||
if (image == null) {
|
||||
return Icon(Icons.error);
|
||||
}
|
||||
|
||||
return image;
|
||||
}),
|
||||
builder: (BuildContext ctx, AsyncSnapshot<Widget> img)
|
||||
{
|
||||
if(!img.hasData)
|
||||
{
|
||||
return Center(child: CircularProgressIndicator(),);
|
||||
}
|
||||
|
||||
return img.data!;
|
||||
}
|
||||
),
|
||||
Icon(Icons.build)];
|
||||
return image;
|
||||
}),
|
||||
builder: (BuildContext ctx, AsyncSnapshot<Widget> img) {
|
||||
if (!img.hasData) {
|
||||
return Center(child: CircularProgressIndicator());
|
||||
}
|
||||
|
||||
return img.data!;
|
||||
},
|
||||
),
|
||||
Icon(Icons.build),
|
||||
];
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
@ -172,7 +164,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
// wireframe for each widget.
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: children,
|
||||
),
|
||||
),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: _incrementCounter,
|
||||
@ -182,4 +174,3 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user