Commit c2e7b6e
Changed files (3)
lib
lib/model/blood_pressure.dart
@@ -1,5 +1,6 @@
import 'dart:io';
+import 'package:blood_pressure_app/screens/error_reporting.dart';
import 'package:collection/collection.dart';
import 'package:flutter/material.dart';
import 'package:path/path.dart';
@@ -24,6 +25,14 @@ class BloodPressureModel extends ChangeNotifier {
return db.execute(
'CREATE TABLE bloodPressureModel(timestamp INTEGER(14) PRIMARY KEY, systolic INTEGER, diastolic INTEGER, pulse INTEGER, notes STRING)');
},
+ onUpgrade: (db, oldVersion, newVersion) async {
+ if (oldVersion == 1 && newVersion == 2) {
+ // TODO
+ } else {
+ await ErrorReporting.reportCriticalError('Unsupported database upgrade', 'Attempted to upgrade the measurement database from version $oldVersion to version $newVersion, which is not supported. This action failed to avoid data loss. Please contact the app developer by opening an issue with the link below or writing an email to contact@derdilla.com.');
+ // TODO: error, open emergency page
+ }
+ },
version: 1,
);
}
@@ -107,6 +116,7 @@ class BloodPressureRecord {
final int? diastolic;
final int? pulse;
final String notes;
+ final MeasurementNeedlePin? needlePin;
//TODO: when adding a color / needle pin for entries:
// - the whole row in the table can be with that bg color
// - add lots of test to make sure this doesn't break records
lib/screens/error_reporting.dart
@@ -9,7 +9,6 @@ import 'package:shared_preferences/shared_preferences.dart';
import 'package:sqflite/sqflite.dart';
import 'package:url_launcher/url_launcher.dart';
-// TODO: test
class ErrorReporting {
static bool isErrorState = false;
ErrorReporting._create();
@@ -59,6 +58,7 @@ class ErrorScreen extends StatelessWidget {
builder: (context) {
final scaffoldMessenger = ScaffoldMessenger.of(context);
return SingleChildScrollView(
+ padding: const EdgeInsets.symmetric(horizontal: 10),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
@@ -66,7 +66,7 @@ class ErrorScreen extends StatelessWidget {
Text('App version: ${debugInfo.version}'),
Text('Build number: ${debugInfo.buildNumber}'),
const Divider(),
- Text(title),
+ Text(title, style: const TextStyle(fontSize: 20, ), ),
Text(text),
const Divider(),
TextButton(
lib/main.dart
@@ -15,6 +15,8 @@ void main() async {
// Reset the step size intervall to current on startup
settingsModel.changeStepSize(settingsModel.graphStepSize);
+ // TODO error handling: https://docs.flutter.dev/testing/errors#handling-all-types-of-errors
+
runApp(MultiProvider(providers: [
ChangeNotifierProvider(create: (context) => dataModel),
ChangeNotifierProvider(create: (context) => settingsModel),