added export button for testing read operation on db

main
Julian Gegner 2023-02-25 18:56:07 +01:00
parent be600f98c8
commit e049aceb8f
1 changed files with 20 additions and 0 deletions

View File

@ -1,9 +1,12 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:mobile_scanner/mobile_scanner.dart'; import 'package:mobile_scanner/mobile_scanner.dart';
import 'package:smoke_cess_app/models/mood.dart';
import 'package:smoke_cess_app/models/settings.dart'; import 'package:smoke_cess_app/models/settings.dart';
import 'package:smoke_cess_app/service/database_service.dart';
import 'package:smoke_cess_app/service/json_service.dart'; import 'package:smoke_cess_app/service/json_service.dart';
import 'package:smoke_cess_app/service/settings_service.dart'; import 'package:smoke_cess_app/service/settings_service.dart';
import '../models/sleep.dart';
import '../widgets/missing_config_popup.dart'; import '../widgets/missing_config_popup.dart';
class ScannerPage extends StatefulWidget { class ScannerPage extends StatefulWidget {
@ -69,6 +72,23 @@ class ScannerPageState extends State<ScannerPage> {
loadSettingsFromLocalJSON(); loadSettingsFromLocalJSON();
}, },
child: const Text('Read JSON'), child: const Text('Read JSON'),
),
const SizedBox(height: 30),
ElevatedButton(
style: ElevatedButton.styleFrom(
textStyle: const TextStyle(fontSize: 20)),
onPressed: () async {
List<Mood> moods = await DatabaseService.instance.getMoodRecords();
List<Sleep> sleeps =
await DatabaseService.instance.getSleepRecords();
for (Mood mood in moods) {
print(mood.toCSV());
}
for (Sleep sleep in sleeps) {
print(sleep.toCSV());
}
},
child: const Text('Export'),
) )
], ],
)); ));