From d558a8f5ad4e5132c2ca8b7c21b5f6e551d2ca7b Mon Sep 17 00:00:00 2001 From: Brandon Presley Date: Sun, 9 Apr 2023 14:39:41 +1200 Subject: [PATCH] Use moor as a ORM for the settings page --- analysis_options.yaml | 1 + lib/database.dart | 35 + lib/database.g.dart | 709 ++++++++++++++++++ lib/main.dart | 5 +- lib/settings.dart | 38 + lib/settings_page.dart | 178 ++++- linux/flutter/generated_plugin_registrant.cc | 4 + linux/flutter/generated_plugins.cmake | 1 + macos/Flutter/GeneratedPluginRegistrant.swift | 4 + pubspec.lock | 512 +++++++++++++ pubspec.yaml | 6 + .../flutter/generated_plugin_registrant.cc | 3 + windows/flutter/generated_plugins.cmake | 1 + 13 files changed, 1494 insertions(+), 3 deletions(-) create mode 100644 lib/database.dart create mode 100644 lib/database.g.dart create mode 100644 lib/settings.dart diff --git a/analysis_options.yaml b/analysis_options.yaml index 61b6c4d..801e26a 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -22,6 +22,7 @@ linter: # `// ignore_for_file: name_of_lint` syntax on the line or in the file # producing the lint. rules: + curly_braces_in_flow_control_structures: false # avoid_print: false # Uncomment to disable the `avoid_print` rule # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule diff --git a/lib/database.dart b/lib/database.dart new file mode 100644 index 0000000..51ff6ab --- /dev/null +++ b/lib/database.dart @@ -0,0 +1,35 @@ +import 'dart:io'; + +import 'package:moor/ffi.dart'; +import 'package:moor/moor.dart'; +import 'package:path/path.dart'; +import 'package:path_provider/path_provider.dart'; +import 'settings.dart'; + +part 'database.g.dart'; + +@UseMoor(tables: [Settings]) +class MyDatabase extends _$MyDatabase { + MyDatabase() : super(_openConnection()); + + @override + int get schemaVersion => 1; + + @override + MigrationStrategy get migration => MigrationStrategy( + onCreate: (Migrator m) async { + await m.createAll(); + }, + onUpgrade: (Migrator m, int from, int to) async { + // no migrations yet + }, + ); +} + +LazyDatabase _openConnection() { + return LazyDatabase(() async { + final dbFolder = await getApplicationDocumentsDirectory(); + final file = File(join(dbFolder.path, 'massive.db')); + return VmDatabase(file, logStatements: true); + }); +} diff --git a/lib/database.g.dart b/lib/database.g.dart new file mode 100644 index 0000000..0c6b0f7 --- /dev/null +++ b/lib/database.g.dart @@ -0,0 +1,709 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'database.dart'; + +// ************************************************************************** +// MoorGenerator +// ************************************************************************** + +// ignore_for_file: type=lint +class Setting extends DataClass implements Insertable { + final bool alarm; + final bool vibrate; + final String sound; + final bool notify; + final bool images; + final bool showUnit; + final String? lightColor; + final String? darkColor; + final bool steps; + final String date; + final bool showDate; + final String theme; + final bool showSets; + final bool noSound; + final bool backup; + Setting( + {required this.alarm, + required this.vibrate, + required this.sound, + required this.notify, + required this.images, + required this.showUnit, + this.lightColor, + this.darkColor, + required this.steps, + required this.date, + required this.showDate, + required this.theme, + required this.showSets, + required this.noSound, + required this.backup}); + factory Setting.fromData(Map data, GeneratedDatabase db, + {String? prefix}) { + final effectivePrefix = prefix ?? ''; + return Setting( + alarm: const BoolType() + .mapFromDatabaseResponse(data['${effectivePrefix}alarm'])!, + vibrate: const BoolType() + .mapFromDatabaseResponse(data['${effectivePrefix}vibrate'])!, + sound: const StringType() + .mapFromDatabaseResponse(data['${effectivePrefix}sound'])!, + notify: const BoolType() + .mapFromDatabaseResponse(data['${effectivePrefix}notify'])!, + images: const BoolType() + .mapFromDatabaseResponse(data['${effectivePrefix}images'])!, + showUnit: const BoolType() + .mapFromDatabaseResponse(data['${effectivePrefix}show_unit'])!, + lightColor: const StringType() + .mapFromDatabaseResponse(data['${effectivePrefix}light_color']), + darkColor: const StringType() + .mapFromDatabaseResponse(data['${effectivePrefix}dark_color']), + steps: const BoolType() + .mapFromDatabaseResponse(data['${effectivePrefix}steps'])!, + date: const StringType() + .mapFromDatabaseResponse(data['${effectivePrefix}date'])!, + showDate: const BoolType() + .mapFromDatabaseResponse(data['${effectivePrefix}show_date'])!, + theme: const StringType() + .mapFromDatabaseResponse(data['${effectivePrefix}theme'])!, + showSets: const BoolType() + .mapFromDatabaseResponse(data['${effectivePrefix}show_sets'])!, + noSound: const BoolType() + .mapFromDatabaseResponse(data['${effectivePrefix}no_sound'])!, + backup: const BoolType() + .mapFromDatabaseResponse(data['${effectivePrefix}backup'])!, + ); + } + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['alarm'] = Variable(alarm); + map['vibrate'] = Variable(vibrate); + map['sound'] = Variable(sound); + map['notify'] = Variable(notify); + map['images'] = Variable(images); + map['show_unit'] = Variable(showUnit); + if (!nullToAbsent || lightColor != null) { + map['light_color'] = Variable(lightColor); + } + if (!nullToAbsent || darkColor != null) { + map['dark_color'] = Variable(darkColor); + } + map['steps'] = Variable(steps); + map['date'] = Variable(date); + map['show_date'] = Variable(showDate); + map['theme'] = Variable(theme); + map['show_sets'] = Variable(showSets); + map['no_sound'] = Variable(noSound); + map['backup'] = Variable(backup); + return map; + } + + SettingsCompanion toCompanion(bool nullToAbsent) { + return SettingsCompanion( + alarm: Value(alarm), + vibrate: Value(vibrate), + sound: Value(sound), + notify: Value(notify), + images: Value(images), + showUnit: Value(showUnit), + lightColor: lightColor == null && nullToAbsent + ? const Value.absent() + : Value(lightColor), + darkColor: darkColor == null && nullToAbsent + ? const Value.absent() + : Value(darkColor), + steps: Value(steps), + date: Value(date), + showDate: Value(showDate), + theme: Value(theme), + showSets: Value(showSets), + noSound: Value(noSound), + backup: Value(backup), + ); + } + + factory Setting.fromJson(Map json, + {ValueSerializer? serializer}) { + serializer ??= moorRuntimeOptions.defaultSerializer; + return Setting( + alarm: serializer.fromJson(json['alarm']), + vibrate: serializer.fromJson(json['vibrate']), + sound: serializer.fromJson(json['sound']), + notify: serializer.fromJson(json['notify']), + images: serializer.fromJson(json['images']), + showUnit: serializer.fromJson(json['showUnit']), + lightColor: serializer.fromJson(json['lightColor']), + darkColor: serializer.fromJson(json['darkColor']), + steps: serializer.fromJson(json['steps']), + date: serializer.fromJson(json['date']), + showDate: serializer.fromJson(json['showDate']), + theme: serializer.fromJson(json['theme']), + showSets: serializer.fromJson(json['showSets']), + noSound: serializer.fromJson(json['noSound']), + backup: serializer.fromJson(json['backup']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= moorRuntimeOptions.defaultSerializer; + return { + 'alarm': serializer.toJson(alarm), + 'vibrate': serializer.toJson(vibrate), + 'sound': serializer.toJson(sound), + 'notify': serializer.toJson(notify), + 'images': serializer.toJson(images), + 'showUnit': serializer.toJson(showUnit), + 'lightColor': serializer.toJson(lightColor), + 'darkColor': serializer.toJson(darkColor), + 'steps': serializer.toJson(steps), + 'date': serializer.toJson(date), + 'showDate': serializer.toJson(showDate), + 'theme': serializer.toJson(theme), + 'showSets': serializer.toJson(showSets), + 'noSound': serializer.toJson(noSound), + 'backup': serializer.toJson(backup), + }; + } + + Setting copyWith( + {bool? alarm, + bool? vibrate, + String? sound, + bool? notify, + bool? images, + bool? showUnit, + String? lightColor, + String? darkColor, + bool? steps, + String? date, + bool? showDate, + String? theme, + bool? showSets, + bool? noSound, + bool? backup}) => + Setting( + alarm: alarm ?? this.alarm, + vibrate: vibrate ?? this.vibrate, + sound: sound ?? this.sound, + notify: notify ?? this.notify, + images: images ?? this.images, + showUnit: showUnit ?? this.showUnit, + lightColor: lightColor ?? this.lightColor, + darkColor: darkColor ?? this.darkColor, + steps: steps ?? this.steps, + date: date ?? this.date, + showDate: showDate ?? this.showDate, + theme: theme ?? this.theme, + showSets: showSets ?? this.showSets, + noSound: noSound ?? this.noSound, + backup: backup ?? this.backup, + ); + @override + String toString() { + return (StringBuffer('Setting(') + ..write('alarm: $alarm, ') + ..write('vibrate: $vibrate, ') + ..write('sound: $sound, ') + ..write('notify: $notify, ') + ..write('images: $images, ') + ..write('showUnit: $showUnit, ') + ..write('lightColor: $lightColor, ') + ..write('darkColor: $darkColor, ') + ..write('steps: $steps, ') + ..write('date: $date, ') + ..write('showDate: $showDate, ') + ..write('theme: $theme, ') + ..write('showSets: $showSets, ') + ..write('noSound: $noSound, ') + ..write('backup: $backup') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + alarm, + vibrate, + sound, + notify, + images, + showUnit, + lightColor, + darkColor, + steps, + date, + showDate, + theme, + showSets, + noSound, + backup); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is Setting && + other.alarm == this.alarm && + other.vibrate == this.vibrate && + other.sound == this.sound && + other.notify == this.notify && + other.images == this.images && + other.showUnit == this.showUnit && + other.lightColor == this.lightColor && + other.darkColor == this.darkColor && + other.steps == this.steps && + other.date == this.date && + other.showDate == this.showDate && + other.theme == this.theme && + other.showSets == this.showSets && + other.noSound == this.noSound && + other.backup == this.backup); +} + +class SettingsCompanion extends UpdateCompanion { + final Value alarm; + final Value vibrate; + final Value sound; + final Value notify; + final Value images; + final Value showUnit; + final Value lightColor; + final Value darkColor; + final Value steps; + final Value date; + final Value showDate; + final Value theme; + final Value showSets; + final Value noSound; + final Value backup; + const SettingsCompanion({ + this.alarm = const Value.absent(), + this.vibrate = const Value.absent(), + this.sound = const Value.absent(), + this.notify = const Value.absent(), + this.images = const Value.absent(), + this.showUnit = const Value.absent(), + this.lightColor = const Value.absent(), + this.darkColor = const Value.absent(), + this.steps = const Value.absent(), + this.date = const Value.absent(), + this.showDate = const Value.absent(), + this.theme = const Value.absent(), + this.showSets = const Value.absent(), + this.noSound = const Value.absent(), + this.backup = const Value.absent(), + }); + SettingsCompanion.insert({ + required bool alarm, + required bool vibrate, + required String sound, + required bool notify, + required bool images, + required bool showUnit, + this.lightColor = const Value.absent(), + this.darkColor = const Value.absent(), + required bool steps, + required String date, + required bool showDate, + required String theme, + required bool showSets, + required bool noSound, + required bool backup, + }) : alarm = Value(alarm), + vibrate = Value(vibrate), + sound = Value(sound), + notify = Value(notify), + images = Value(images), + showUnit = Value(showUnit), + steps = Value(steps), + date = Value(date), + showDate = Value(showDate), + theme = Value(theme), + showSets = Value(showSets), + noSound = Value(noSound), + backup = Value(backup); + static Insertable custom({ + Expression? alarm, + Expression? vibrate, + Expression? sound, + Expression? notify, + Expression? images, + Expression? showUnit, + Expression? lightColor, + Expression? darkColor, + Expression? steps, + Expression? date, + Expression? showDate, + Expression? theme, + Expression? showSets, + Expression? noSound, + Expression? backup, + }) { + return RawValuesInsertable({ + if (alarm != null) 'alarm': alarm, + if (vibrate != null) 'vibrate': vibrate, + if (sound != null) 'sound': sound, + if (notify != null) 'notify': notify, + if (images != null) 'images': images, + if (showUnit != null) 'show_unit': showUnit, + if (lightColor != null) 'light_color': lightColor, + if (darkColor != null) 'dark_color': darkColor, + if (steps != null) 'steps': steps, + if (date != null) 'date': date, + if (showDate != null) 'show_date': showDate, + if (theme != null) 'theme': theme, + if (showSets != null) 'show_sets': showSets, + if (noSound != null) 'no_sound': noSound, + if (backup != null) 'backup': backup, + }); + } + + SettingsCompanion copyWith( + {Value? alarm, + Value? vibrate, + Value? sound, + Value? notify, + Value? images, + Value? showUnit, + Value? lightColor, + Value? darkColor, + Value? steps, + Value? date, + Value? showDate, + Value? theme, + Value? showSets, + Value? noSound, + Value? backup}) { + return SettingsCompanion( + alarm: alarm ?? this.alarm, + vibrate: vibrate ?? this.vibrate, + sound: sound ?? this.sound, + notify: notify ?? this.notify, + images: images ?? this.images, + showUnit: showUnit ?? this.showUnit, + lightColor: lightColor ?? this.lightColor, + darkColor: darkColor ?? this.darkColor, + steps: steps ?? this.steps, + date: date ?? this.date, + showDate: showDate ?? this.showDate, + theme: theme ?? this.theme, + showSets: showSets ?? this.showSets, + noSound: noSound ?? this.noSound, + backup: backup ?? this.backup, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (alarm.present) { + map['alarm'] = Variable(alarm.value); + } + if (vibrate.present) { + map['vibrate'] = Variable(vibrate.value); + } + if (sound.present) { + map['sound'] = Variable(sound.value); + } + if (notify.present) { + map['notify'] = Variable(notify.value); + } + if (images.present) { + map['images'] = Variable(images.value); + } + if (showUnit.present) { + map['show_unit'] = Variable(showUnit.value); + } + if (lightColor.present) { + map['light_color'] = Variable(lightColor.value); + } + if (darkColor.present) { + map['dark_color'] = Variable(darkColor.value); + } + if (steps.present) { + map['steps'] = Variable(steps.value); + } + if (date.present) { + map['date'] = Variable(date.value); + } + if (showDate.present) { + map['show_date'] = Variable(showDate.value); + } + if (theme.present) { + map['theme'] = Variable(theme.value); + } + if (showSets.present) { + map['show_sets'] = Variable(showSets.value); + } + if (noSound.present) { + map['no_sound'] = Variable(noSound.value); + } + if (backup.present) { + map['backup'] = Variable(backup.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('SettingsCompanion(') + ..write('alarm: $alarm, ') + ..write('vibrate: $vibrate, ') + ..write('sound: $sound, ') + ..write('notify: $notify, ') + ..write('images: $images, ') + ..write('showUnit: $showUnit, ') + ..write('lightColor: $lightColor, ') + ..write('darkColor: $darkColor, ') + ..write('steps: $steps, ') + ..write('date: $date, ') + ..write('showDate: $showDate, ') + ..write('theme: $theme, ') + ..write('showSets: $showSets, ') + ..write('noSound: $noSound, ') + ..write('backup: $backup') + ..write(')')) + .toString(); + } +} + +class $SettingsTable extends Settings with TableInfo<$SettingsTable, Setting> { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + $SettingsTable(this.attachedDatabase, [this._alias]); + final VerificationMeta _alarmMeta = const VerificationMeta('alarm'); + @override + late final GeneratedColumn alarm = GeneratedColumn( + 'alarm', aliasedName, false, + type: const BoolType(), + requiredDuringInsert: true, + defaultConstraints: 'CHECK (alarm IN (0, 1))'); + final VerificationMeta _vibrateMeta = const VerificationMeta('vibrate'); + @override + late final GeneratedColumn vibrate = GeneratedColumn( + 'vibrate', aliasedName, false, + type: const BoolType(), + requiredDuringInsert: true, + defaultConstraints: 'CHECK (vibrate IN (0, 1))'); + final VerificationMeta _soundMeta = const VerificationMeta('sound'); + @override + late final GeneratedColumn sound = GeneratedColumn( + 'sound', aliasedName, false, + type: const StringType(), requiredDuringInsert: true); + final VerificationMeta _notifyMeta = const VerificationMeta('notify'); + @override + late final GeneratedColumn notify = GeneratedColumn( + 'notify', aliasedName, false, + type: const BoolType(), + requiredDuringInsert: true, + defaultConstraints: 'CHECK (notify IN (0, 1))'); + final VerificationMeta _imagesMeta = const VerificationMeta('images'); + @override + late final GeneratedColumn images = GeneratedColumn( + 'images', aliasedName, false, + type: const BoolType(), + requiredDuringInsert: true, + defaultConstraints: 'CHECK (images IN (0, 1))'); + final VerificationMeta _showUnitMeta = const VerificationMeta('showUnit'); + @override + late final GeneratedColumn showUnit = GeneratedColumn( + 'show_unit', aliasedName, false, + type: const BoolType(), + requiredDuringInsert: true, + defaultConstraints: 'CHECK (show_unit IN (0, 1))'); + final VerificationMeta _lightColorMeta = const VerificationMeta('lightColor'); + @override + late final GeneratedColumn lightColor = GeneratedColumn( + 'light_color', aliasedName, true, + type: const StringType(), requiredDuringInsert: false); + final VerificationMeta _darkColorMeta = const VerificationMeta('darkColor'); + @override + late final GeneratedColumn darkColor = GeneratedColumn( + 'dark_color', aliasedName, true, + type: const StringType(), requiredDuringInsert: false); + final VerificationMeta _stepsMeta = const VerificationMeta('steps'); + @override + late final GeneratedColumn steps = GeneratedColumn( + 'steps', aliasedName, false, + type: const BoolType(), + requiredDuringInsert: true, + defaultConstraints: 'CHECK (steps IN (0, 1))'); + final VerificationMeta _dateMeta = const VerificationMeta('date'); + @override + late final GeneratedColumn date = GeneratedColumn( + 'date', aliasedName, false, + type: const StringType(), requiredDuringInsert: true); + final VerificationMeta _showDateMeta = const VerificationMeta('showDate'); + @override + late final GeneratedColumn showDate = GeneratedColumn( + 'show_date', aliasedName, false, + type: const BoolType(), + requiredDuringInsert: true, + defaultConstraints: 'CHECK (show_date IN (0, 1))'); + final VerificationMeta _themeMeta = const VerificationMeta('theme'); + @override + late final GeneratedColumn theme = GeneratedColumn( + 'theme', aliasedName, false, + type: const StringType(), requiredDuringInsert: true); + final VerificationMeta _showSetsMeta = const VerificationMeta('showSets'); + @override + late final GeneratedColumn showSets = GeneratedColumn( + 'show_sets', aliasedName, false, + type: const BoolType(), + requiredDuringInsert: true, + defaultConstraints: 'CHECK (show_sets IN (0, 1))'); + final VerificationMeta _noSoundMeta = const VerificationMeta('noSound'); + @override + late final GeneratedColumn noSound = GeneratedColumn( + 'no_sound', aliasedName, false, + type: const BoolType(), + requiredDuringInsert: true, + defaultConstraints: 'CHECK (no_sound IN (0, 1))'); + final VerificationMeta _backupMeta = const VerificationMeta('backup'); + @override + late final GeneratedColumn backup = GeneratedColumn( + 'backup', aliasedName, false, + type: const BoolType(), + requiredDuringInsert: true, + defaultConstraints: 'CHECK (backup IN (0, 1))'); + @override + List get $columns => [ + alarm, + vibrate, + sound, + notify, + images, + showUnit, + lightColor, + darkColor, + steps, + date, + showDate, + theme, + showSets, + noSound, + backup + ]; + @override + String get aliasedName => _alias ?? 'settings'; + @override + String get actualTableName => 'settings'; + @override + VerificationContext validateIntegrity(Insertable instance, + {bool isInserting = false}) { + final context = VerificationContext(); + final data = instance.toColumns(true); + if (data.containsKey('alarm')) { + context.handle( + _alarmMeta, alarm.isAcceptableOrUnknown(data['alarm']!, _alarmMeta)); + } else if (isInserting) { + context.missing(_alarmMeta); + } + if (data.containsKey('vibrate')) { + context.handle(_vibrateMeta, + vibrate.isAcceptableOrUnknown(data['vibrate']!, _vibrateMeta)); + } else if (isInserting) { + context.missing(_vibrateMeta); + } + if (data.containsKey('sound')) { + context.handle( + _soundMeta, sound.isAcceptableOrUnknown(data['sound']!, _soundMeta)); + } else if (isInserting) { + context.missing(_soundMeta); + } + if (data.containsKey('notify')) { + context.handle(_notifyMeta, + notify.isAcceptableOrUnknown(data['notify']!, _notifyMeta)); + } else if (isInserting) { + context.missing(_notifyMeta); + } + if (data.containsKey('images')) { + context.handle(_imagesMeta, + images.isAcceptableOrUnknown(data['images']!, _imagesMeta)); + } else if (isInserting) { + context.missing(_imagesMeta); + } + if (data.containsKey('show_unit')) { + context.handle(_showUnitMeta, + showUnit.isAcceptableOrUnknown(data['show_unit']!, _showUnitMeta)); + } else if (isInserting) { + context.missing(_showUnitMeta); + } + if (data.containsKey('light_color')) { + context.handle( + _lightColorMeta, + lightColor.isAcceptableOrUnknown( + data['light_color']!, _lightColorMeta)); + } + if (data.containsKey('dark_color')) { + context.handle(_darkColorMeta, + darkColor.isAcceptableOrUnknown(data['dark_color']!, _darkColorMeta)); + } + if (data.containsKey('steps')) { + context.handle( + _stepsMeta, steps.isAcceptableOrUnknown(data['steps']!, _stepsMeta)); + } else if (isInserting) { + context.missing(_stepsMeta); + } + if (data.containsKey('date')) { + context.handle( + _dateMeta, date.isAcceptableOrUnknown(data['date']!, _dateMeta)); + } else if (isInserting) { + context.missing(_dateMeta); + } + if (data.containsKey('show_date')) { + context.handle(_showDateMeta, + showDate.isAcceptableOrUnknown(data['show_date']!, _showDateMeta)); + } else if (isInserting) { + context.missing(_showDateMeta); + } + if (data.containsKey('theme')) { + context.handle( + _themeMeta, theme.isAcceptableOrUnknown(data['theme']!, _themeMeta)); + } else if (isInserting) { + context.missing(_themeMeta); + } + if (data.containsKey('show_sets')) { + context.handle(_showSetsMeta, + showSets.isAcceptableOrUnknown(data['show_sets']!, _showSetsMeta)); + } else if (isInserting) { + context.missing(_showSetsMeta); + } + if (data.containsKey('no_sound')) { + context.handle(_noSoundMeta, + noSound.isAcceptableOrUnknown(data['no_sound']!, _noSoundMeta)); + } else if (isInserting) { + context.missing(_noSoundMeta); + } + if (data.containsKey('backup')) { + context.handle(_backupMeta, + backup.isAcceptableOrUnknown(data['backup']!, _backupMeta)); + } else if (isInserting) { + context.missing(_backupMeta); + } + return context; + } + + @override + Set get $primaryKey => {}; + @override + Setting map(Map data, {String? tablePrefix}) { + return Setting.fromData(data, attachedDatabase, + prefix: tablePrefix != null ? '$tablePrefix.' : null); + } + + @override + $SettingsTable createAlias(String alias) { + return $SettingsTable(attachedDatabase, alias); + } +} + +abstract class _$MyDatabase extends GeneratedDatabase { + _$MyDatabase(QueryExecutor e) : super(SqlTypeSystem.defaultInstance, e); + late final $SettingsTable settings = $SettingsTable(this); + @override + Iterable get allTables => allSchemaEntities.whereType(); + @override + List get allSchemaEntities => [settings]; +} diff --git a/lib/main.dart b/lib/main.dart index c9df73a..925219d 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:fmassive/best_page.dart'; +import 'package:fmassive/database.dart'; import 'package:fmassive/edit_set.dart'; import 'package:fmassive/gym_set.dart'; import 'package:fmassive/home_page.dart'; @@ -8,6 +9,8 @@ import 'package:fmassive/settings_page.dart'; import 'package:fmassive/timer_page.dart'; import 'package:fmassive/workouts_page.dart'; +MyDatabase db = MyDatabase(); + void main() { runApp(MyApp()); } @@ -28,7 +31,7 @@ class MyApp extends StatelessWidget { '/best': (context) => const BestPage(), '/workouts': (context) => const WorkoutsPage(), '/timer': (context) => const TimerPage(), - '/settings': (context) => const SettingsPage(), + '/settings': (context) => SettingsPage(), '/edit-set': (context) => edit, }; diff --git a/lib/settings.dart b/lib/settings.dart new file mode 100644 index 0000000..72a8658 --- /dev/null +++ b/lib/settings.dart @@ -0,0 +1,38 @@ +import 'package:fmassive/database.dart'; +import 'package:moor/moor.dart'; + +Setting defaultSettings = Setting( + alarm: true, + vibrate: true, + sound: 'default.mp3', + notify: true, + images: true, + showUnit: true, + lightColor: null, + darkColor: null, + steps: true, + date: 'DD/MM/YYYY', + showDate: true, + theme: 'light', + showSets: true, + noSound: false, + backup: false, +); + +class Settings extends Table { + BoolColumn get alarm => boolean()(); + BoolColumn get vibrate => boolean()(); + TextColumn get sound => text()(); + BoolColumn get notify => boolean()(); + BoolColumn get images => boolean()(); + BoolColumn get showUnit => boolean()(); + TextColumn get lightColor => text().nullable()(); + TextColumn get darkColor => text().nullable()(); + BoolColumn get steps => boolean()(); + TextColumn get date => text()(); + BoolColumn get showDate => boolean()(); + TextColumn get theme => text()(); + BoolColumn get showSets => boolean()(); + BoolColumn get noSound => boolean()(); + BoolColumn get backup => boolean()(); +} diff --git a/lib/settings_page.dart b/lib/settings_page.dart index 33f98e2..7023ddd 100644 --- a/lib/settings_page.dart +++ b/lib/settings_page.dart @@ -1,7 +1,21 @@ import 'package:flutter/material.dart'; +import 'package:flutter/material.dart' as material; +import 'package:fmassive/database.dart'; +import 'package:fmassive/main.dart'; +import 'package:fmassive/settings.dart'; +import 'package:moor/moor.dart'; class SettingsPage extends StatelessWidget { - const SettingsPage({super.key}); + SettingsPage({super.key}); + + final List> routes = [ + {'title': 'Home', 'icon': Icons.home}, + {'title': 'Plans', 'icon': Icons.calendar_today}, + {'title': 'Best', 'icon': Icons.star}, + {'title': 'Workouts', 'icon': Icons.fitness_center}, + {'title': 'Timer', 'icon': Icons.timer}, + {'title': 'Settings', 'icon': Icons.settings}, + ]; @override Widget build(BuildContext context) { @@ -9,9 +23,169 @@ class SettingsPage extends StatelessWidget { appBar: AppBar( title: const Text('Settings'), ), + drawer: Drawer( + child: ListView.builder( + itemCount: routes.length, + itemBuilder: (context, index) { + return ListTile( + leading: Icon(routes[index]['icon']), + title: Text(routes[index]['title']), + onTap: () { + Navigator.pop(context); + Navigator.pushNamed( + context, '/${routes[index]['title'].toLowerCase()}'); + }, + ); + }, + ), + ), body: const Center( - child: Text('Welcome to the Settings Page!'), + child: _SettingsPage(), ), ); } } + +class _SettingsPage extends StatefulWidget { + const _SettingsPage({Key? key}) : super(key: key); + + @override + createState() => _SettingsPageState(); +} + +class _SettingsPageState extends State<_SettingsPage> { + late Stream stream; + + final TextEditingController searchController = TextEditingController(); + + void reset() async { + var data = await db.select(db.settings).get(); + if (data.isEmpty) await db.into(db.settings).insert(defaultSettings); + setState(() { + if (data.isEmpty) return; + }); + } + + @override + void initState() { + super.initState(); + stream = db.select(db.settings).watchSingle(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: StreamBuilder( + stream: stream, + builder: (context, snapshot) { + final settings = snapshot.data; + + if (settings == null) + return const Center(child: CircularProgressIndicator()); + + return SingleChildScrollView( + padding: const EdgeInsets.all(8.0), + child: material.Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SwitchListTile( + title: Text('Alarm'), + value: settings.alarm, + onChanged: (value) { + db + .update(db.settings) + .write(SettingsCompanion(alarm: Value(value))); + }, + ), + SwitchListTile( + title: Text('Vibrate'), + value: settings.vibrate, + onChanged: (value) { + db + .update(db.settings) + .write(SettingsCompanion(vibrate: Value(value))); + }, + ), + SwitchListTile( + title: Text('Notify'), + value: settings.notify, + onChanged: (value) { + db + .update(db.settings) + .write(SettingsCompanion(notify: Value(value))); + }, + ), + SwitchListTile( + title: Text('Images'), + value: settings.images, + onChanged: (value) { + db + .update(db.settings) + .write(SettingsCompanion(images: Value(value))); + }, + ), + SwitchListTile( + title: Text('Show Unit'), + value: settings.showUnit, + onChanged: (value) { + db + .update(db.settings) + .write(SettingsCompanion(showUnit: Value(value))); + }, + ), + SwitchListTile( + title: Text('Steps'), + value: settings.steps, + onChanged: (value) { + db + .update(db.settings) + .write(SettingsCompanion(steps: Value(value))); + }, + ), + TextField( + decoration: InputDecoration( + labelText: 'Sound', + ), + onChanged: (value) { + db + .update(db.settings) + .write(SettingsCompanion(sound: Value(value))); + }, + ), + TextField( + decoration: InputDecoration( + labelText: 'Light Color', + ), + onChanged: (value) { + db + .update(db.settings) + .write(SettingsCompanion(lightColor: Value(value))); + }, + ), + TextField( + decoration: InputDecoration( + labelText: 'Dark Color', + ), + onChanged: (value) { + db + .update(db.settings) + .write(SettingsCompanion(darkColor: Value(value))); + }, + ), + TextField( + decoration: InputDecoration( + labelText: 'Date', + ), + onChanged: (value) { + db + .update(db.settings) + .write(SettingsCompanion(date: Value(value))); + }, + ), + ], + ), + ); + }), + ); + } +} diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index e71a16d..2c1ec4f 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -6,6 +6,10 @@ #include "generated_plugin_registrant.h" +#include void fl_register_plugins(FlPluginRegistry* registry) { + g_autoptr(FlPluginRegistrar) sqlite3_flutter_libs_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "Sqlite3FlutterLibsPlugin"); + sqlite3_flutter_libs_plugin_register_with_registrar(sqlite3_flutter_libs_registrar); } diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index 2e1de87..7ea2a80 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -3,6 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST + sqlite3_flutter_libs ) list(APPEND FLUTTER_FFI_PLUGIN_LIST diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 8370e57..d2798e4 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -5,8 +5,12 @@ import FlutterMacOS import Foundation +import path_provider_foundation import sqflite +import sqlite3_flutter_libs func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin")) + Sqlite3FlutterLibsPlugin.register(with: registry.registrar(forPlugin: "Sqlite3FlutterLibsPlugin")) } diff --git a/pubspec.lock b/pubspec.lock index 352ed89..1d604c2 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,6 +1,38 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + _fe_analyzer_shared: + dependency: transitive + description: + name: _fe_analyzer_shared + sha256: "4897882604d919befd350648c7f91926a9d5de99e67b455bf0917cc2362f4bb8" + url: "https://pub.dev" + source: hosted + version: "47.0.0" + analyzer: + dependency: transitive + description: + name: analyzer + sha256: "690e335554a8385bc9d787117d9eb52c0c03ee207a607e593de3c9d71b1cfe80" + url: "https://pub.dev" + source: hosted + version: "4.7.0" + analyzer_plugin: + dependency: transitive + description: + name: analyzer_plugin + sha256: "02b0046b8b9a4c97a238c66f70acd22eec4263dfc8d9205f9dab5cc8630c5a6f" + url: "https://pub.dev" + source: hosted + version: "0.11.1" + args: + dependency: transitive + description: + name: args + sha256: "4cab82a83ffef80b262ddedf47a0a8e56ee6fbf7fe21e6e768b02792034dd440" + url: "https://pub.dev" + source: hosted + version: "2.4.0" async: dependency: transitive description: @@ -17,6 +49,70 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.1" + build: + dependency: transitive + description: + name: build + sha256: "3fbda25365741f8251b39f3917fb3c8e286a96fd068a5a242e11c2012d495777" + url: "https://pub.dev" + source: hosted + version: "2.3.1" + build_config: + dependency: transitive + description: + name: build_config + sha256: bf80fcfb46a29945b423bd9aad884590fb1dc69b330a4d4700cac476af1708d1 + url: "https://pub.dev" + source: hosted + version: "1.1.1" + build_daemon: + dependency: transitive + description: + name: build_daemon + sha256: "757153e5d9cd88253cb13f28c2fb55a537dc31fefd98137549895b5beb7c6169" + url: "https://pub.dev" + source: hosted + version: "3.1.1" + build_resolvers: + dependency: transitive + description: + name: build_resolvers + sha256: "687cf90a3951affac1bd5f9ecb5e3e90b60487f3d9cdc359bb310f8876bb02a6" + url: "https://pub.dev" + source: hosted + version: "2.0.10" + build_runner: + dependency: "direct main" + description: + name: build_runner + sha256: b0a8a7b8a76c493e85f1b84bffa0588859a06197863dba8c9036b15581fd9727 + url: "https://pub.dev" + source: hosted + version: "2.3.3" + build_runner_core: + dependency: transitive + description: + name: build_runner_core + sha256: "14febe0f5bac5ae474117a36099b4de6f1dbc52df6c5e55534b3da9591bf4292" + url: "https://pub.dev" + source: hosted + version: "7.2.7" + built_collection: + dependency: transitive + description: + name: built_collection + sha256: "376e3dd27b51ea877c28d525560790aee2e6fbb5f20e2f85d5081027d94e2100" + url: "https://pub.dev" + source: hosted + version: "5.1.1" + built_value: + dependency: transitive + description: + name: built_value + sha256: "31b7c748fd4b9adf8d25d72a4c4a59ef119f12876cf414f94f8af5131d5fa2b0" + url: "https://pub.dev" + source: hosted + version: "8.4.4" characters: dependency: transitive description: @@ -25,6 +121,30 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.1" + charcode: + dependency: transitive + description: + name: charcode + sha256: fb98c0f6d12c920a02ee2d998da788bca066ca5f148492b7085ee23372b12306 + url: "https://pub.dev" + source: hosted + version: "1.3.1" + checked_yaml: + dependency: transitive + description: + name: checked_yaml + sha256: "3d1505d91afa809d177efd4eed5bb0eb65805097a1463abdd2add076effae311" + url: "https://pub.dev" + source: hosted + version: "2.0.2" + cli_util: + dependency: transitive + description: + name: cli_util + sha256: "66f86e916d285c1a93d3b79587d94bd71984a66aac4ff74e524cfa7877f1395c" + url: "https://pub.dev" + source: hosted + version: "0.3.5" clock: dependency: transitive description: @@ -33,6 +153,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.1.1" + code_builder: + dependency: transitive + description: + name: code_builder + sha256: "0d43dd1288fd145de1ecc9a3948ad4a6d5a82f0a14c4fdd0892260787d975cbe" + url: "https://pub.dev" + source: hosted + version: "4.4.0" collection: dependency: transitive description: @@ -41,6 +169,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.17.0" + convert: + dependency: transitive + description: + name: convert + sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" + url: "https://pub.dev" + source: hosted + version: "3.1.1" + crypto: + dependency: transitive + description: + name: crypto + sha256: aa274aa7774f8964e4f4f38cc994db7b6158dd36e9187aaceaddc994b35c6c67 + url: "https://pub.dev" + source: hosted + version: "3.0.2" cupertino_icons: dependency: "direct main" description: @@ -49,6 +193,30 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.5" + dart_style: + dependency: transitive + description: + name: dart_style + sha256: "7a03456c3490394c8e7665890333e91ae8a49be43542b616e414449ac358acd4" + url: "https://pub.dev" + source: hosted + version: "2.2.4" + drift: + dependency: transitive + description: + name: drift + sha256: "43ae515270f38ffe47702dc920c04d415894bcc6ebdf3e2b6a292cb207ed8cb7" + url: "https://pub.dev" + source: hosted + version: "1.7.1" + drift_dev: + dependency: transitive + description: + name: drift_dev + sha256: "7d51538da971823a158236823cfb299731f720cd55078c6a478bfa4effb69275" + url: "https://pub.dev" + source: hosted + version: "1.7.1" fake_async: dependency: transitive description: @@ -57,6 +225,30 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.1" + ffi: + dependency: transitive + description: + name: ffi + sha256: a38574032c5f1dd06c4aee541789906c12ccaab8ba01446e800d9c5b79c4a978 + url: "https://pub.dev" + source: hosted + version: "2.0.1" + file: + dependency: transitive + description: + name: file + sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" + url: "https://pub.dev" + source: hosted + version: "6.1.4" + fixnum: + dependency: transitive + description: + name: fixnum + sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1" + url: "https://pub.dev" + source: hosted + version: "1.1.0" flutter: dependency: "direct main" description: flutter @@ -75,6 +267,54 @@ packages: description: flutter source: sdk version: "0.0.0" + frontend_server_client: + dependency: transitive + description: + name: frontend_server_client + sha256: "408e3ca148b31c20282ad6f37ebfa6f4bdc8fede5b74bc2f08d9d92b55db3612" + url: "https://pub.dev" + source: hosted + version: "3.2.0" + glob: + dependency: transitive + description: + name: glob + sha256: "4515b5b6ddb505ebdd242a5f2cc5d22d3d6a80013789debfbda7777f47ea308c" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + graphs: + dependency: transitive + description: + name: graphs + sha256: f9e130f3259f52d26f0cfc0e964513796dafed572fa52e45d2f8d6ca14db39b2 + url: "https://pub.dev" + source: hosted + version: "2.2.0" + http_multi_server: + dependency: transitive + description: + name: http_multi_server + sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b" + url: "https://pub.dev" + source: hosted + version: "3.2.1" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" + url: "https://pub.dev" + source: hosted + version: "4.0.2" + io: + dependency: transitive + description: + name: io + sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e" + url: "https://pub.dev" + source: hosted + version: "1.0.4" js: dependency: transitive description: @@ -83,6 +323,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.6.5" + json_annotation: + dependency: transitive + description: + name: json_annotation + sha256: c33da08e136c3df0190bd5bbe51ae1df4a7d96e7954d1d7249fea2968a72d317 + url: "https://pub.dev" + source: hosted + version: "4.8.0" lints: dependency: transitive description: @@ -91,6 +339,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.1" + logging: + dependency: transitive + description: + name: logging + sha256: "04094f2eb032cbb06c6f6e8d3607edcfcb0455e2bb6cbc010cb01171dcb64e6d" + url: "https://pub.dev" + source: hosted + version: "1.1.1" matcher: dependency: transitive description: @@ -115,6 +371,46 @@ packages: url: "https://pub.dev" source: hosted version: "1.8.0" + mime: + dependency: transitive + description: + name: mime + sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e + url: "https://pub.dev" + source: hosted + version: "1.0.4" + moor: + dependency: "direct main" + description: + name: moor + sha256: "3c9500ebb0996592480728a5480e020c881110597416b9f3c6f72e57212bd78c" + url: "https://pub.dev" + source: hosted + version: "4.6.1+1" + moor_flutter: + dependency: "direct main" + description: + name: moor_flutter + sha256: "337babe6977103a765d01a838b5d166483eff0a6a83ad5f997761c247f428cdf" + url: "https://pub.dev" + source: hosted + version: "4.1.0" + moor_generator: + dependency: "direct main" + description: + name: moor_generator + sha256: "511df4d32bc6150456024592e4839fb868eda96b49d8c3515e30781eec6bc31d" + url: "https://pub.dev" + source: hosted + version: "4.6.0+1" + package_config: + dependency: transitive + description: + name: package_config + sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd" + url: "https://pub.dev" + source: hosted + version: "2.1.0" path: dependency: "direct main" description: @@ -123,11 +419,139 @@ packages: url: "https://pub.dev" source: hosted version: "1.8.2" + path_provider: + dependency: "direct main" + description: + name: path_provider + sha256: c7edf82217d4b2952b2129a61d3ad60f1075b9299e629e149a8d2e39c2e6aad4 + url: "https://pub.dev" + source: hosted + version: "2.0.14" + path_provider_android: + dependency: transitive + description: + name: path_provider_android + sha256: "019f18c9c10ae370b08dce1f3e3b73bc9f58e7f087bb5e921f06529438ac0ae7" + url: "https://pub.dev" + source: hosted + version: "2.0.24" + path_provider_foundation: + dependency: transitive + description: + name: path_provider_foundation + sha256: "818b2dc38b0f178e0ea3f7cf3b28146faab11375985d815942a68eee11c2d0f7" + url: "https://pub.dev" + source: hosted + version: "2.2.1" + path_provider_linux: + dependency: transitive + description: + name: path_provider_linux + sha256: "2ae08f2216225427e64ad224a24354221c2c7907e448e6e0e8b57b1eb9f10ad1" + url: "https://pub.dev" + source: hosted + version: "2.1.10" + path_provider_platform_interface: + dependency: transitive + description: + name: path_provider_platform_interface + sha256: "57585299a729335f1298b43245842678cb9f43a6310351b18fb577d6e33165ec" + url: "https://pub.dev" + source: hosted + version: "2.0.6" + path_provider_windows: + dependency: transitive + description: + name: path_provider_windows + sha256: f53720498d5a543f9607db4b0e997c4b5438884de25b0f73098cc2671a51b130 + url: "https://pub.dev" + source: hosted + version: "2.1.5" + platform: + dependency: transitive + description: + name: platform + sha256: "4a451831508d7d6ca779f7ac6e212b4023dd5a7d08a27a63da33756410e32b76" + url: "https://pub.dev" + source: hosted + version: "3.1.0" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: "6a2128648c854906c53fa8e33986fc0247a1116122f9534dd20e3ab9e16a32bc" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + pool: + dependency: transitive + description: + name: pool + sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" + url: "https://pub.dev" + source: hosted + version: "1.5.1" + process: + dependency: transitive + description: + name: process + sha256: "53fd8db9cec1d37b0574e12f07520d582019cb6c44abf5479a01505099a34a09" + url: "https://pub.dev" + source: hosted + version: "4.2.4" + pub_semver: + dependency: transitive + description: + name: pub_semver + sha256: "307de764d305289ff24ad257ad5c5793ce56d04947599ad68b3baa124105fc17" + url: "https://pub.dev" + source: hosted + version: "2.1.3" + pubspec_parse: + dependency: transitive + description: + name: pubspec_parse + sha256: ec85d7d55339d85f44ec2b682a82fea340071e8978257e5a43e69f79e98ef50c + url: "https://pub.dev" + source: hosted + version: "1.2.2" + recase: + dependency: transitive + description: + name: recase + sha256: e4eb4ec2dcdee52dcf99cb4ceabaffc631d7424ee55e56f280bc039737f89213 + url: "https://pub.dev" + source: hosted + version: "4.1.0" + shelf: + dependency: transitive + description: + name: shelf + sha256: c24a96135a2ccd62c64b69315a14adc5c3419df63b4d7c05832a346fdb73682c + url: "https://pub.dev" + source: hosted + version: "1.4.0" + shelf_web_socket: + dependency: transitive + description: + name: shelf_web_socket + sha256: a988c0e8d8ffbdb8a28aa7ec8e449c260f3deb808781fe1284d22c5bba7156e8 + url: "https://pub.dev" + source: hosted + version: "1.0.3" sky_engine: dependency: transitive description: flutter source: sdk version: "0.0.99" + source_gen: + dependency: transitive + description: + name: source_gen + sha256: "2d79738b6bbf38a43920e2b8d189e9a3ce6cc201f4b8fc76be5e4fe377b1c38d" + url: "https://pub.dev" + source: hosted + version: "1.2.6" source_span: dependency: transitive description: @@ -152,6 +576,30 @@ packages: url: "https://pub.dev" source: hosted version: "2.4.3" + sqlite3: + dependency: transitive + description: + name: sqlite3 + sha256: "822d321a008e194d7929357e5b58d2e4a04ab670d137182f9759152aa33180ff" + url: "https://pub.dev" + source: hosted + version: "1.10.1" + sqlite3_flutter_libs: + dependency: "direct main" + description: + name: sqlite3_flutter_libs + sha256: "02f80aea54a19a36b347dedf6d4181ecd9107f5831ea6139cfd0376a3de197ba" + url: "https://pub.dev" + source: hosted + version: "0.5.13" + sqlparser: + dependency: transitive + description: + name: sqlparser + sha256: "9ed8f4a24a2a243e23ad267bb50378cb75c7de0b200b5336229b2d6096e6a5df" + url: "https://pub.dev" + source: hosted + version: "0.22.0" stack_trace: dependency: transitive description: @@ -168,6 +616,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.1" + stream_transform: + dependency: transitive + description: + name: stream_transform + sha256: "14a00e794c7c11aa145a170587321aedce29769c08d7f58b1d141da75e3b1c6f" + url: "https://pub.dev" + source: hosted + version: "2.1.0" string_scanner: dependency: transitive description: @@ -200,6 +656,22 @@ packages: url: "https://pub.dev" source: hosted version: "0.4.16" + timing: + dependency: transitive + description: + name: timing + sha256: "70a3b636575d4163c477e6de42f247a23b315ae20e86442bebe32d3cabf61c32" + url: "https://pub.dev" + source: hosted + version: "1.0.1" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: "26f87ade979c47a150c9eaab93ccd2bebe70a27dc0b4b29517f2904f04eb11a5" + url: "https://pub.dev" + source: hosted + version: "1.3.1" vector_math: dependency: transitive description: @@ -208,6 +680,46 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" + watcher: + dependency: transitive + description: + name: watcher + sha256: "6a7f46926b01ce81bfc339da6a7f20afbe7733eff9846f6d6a5466aa4c6667c0" + url: "https://pub.dev" + source: hosted + version: "1.0.2" + web_socket_channel: + dependency: transitive + description: + name: web_socket_channel + sha256: ca49c0bc209c687b887f30527fb6a9d80040b072cc2990f34b9bec3e7663101b + url: "https://pub.dev" + source: hosted + version: "2.3.0" + win32: + dependency: transitive + description: + name: win32 + sha256: a6f0236dbda0f63aa9a25ad1ff9a9d8a4eaaa5012da0dc59d21afdb1dc361ca4 + url: "https://pub.dev" + source: hosted + version: "3.1.4" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + sha256: ee1505df1426458f7f60aac270645098d318a8b4766d85fde75f76f2e21807d1 + url: "https://pub.dev" + source: hosted + version: "1.0.0" + yaml: + dependency: transitive + description: + name: yaml + sha256: "23812a9b125b48d4007117254bca50abb6c712352927eece9e155207b1db2370" + url: "https://pub.dev" + source: hosted + version: "3.1.1" sdks: dart: ">=2.19.5 <3.0.0" flutter: ">=3.3.0" diff --git a/pubspec.yaml b/pubspec.yaml index 3fa9f1d..7c43a92 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -36,6 +36,12 @@ dependencies: cupertino_icons: ^1.0.2 path: ^1.8.2 sqflite: ^2.2.6 + moor_flutter: ^4.1.0 + build_runner: ^2.3.3 + moor_generator: ^4.6.0+1 + path_provider: ^2.0.14 + sqlite3_flutter_libs: ^0.5.13 + moor: ^4.6.1+1 dev_dependencies: flutter_test: diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 8b6d468..988f3c8 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -6,6 +6,9 @@ #include "generated_plugin_registrant.h" +#include void RegisterPlugins(flutter::PluginRegistry* registry) { + Sqlite3FlutterLibsPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("Sqlite3FlutterLibsPlugin")); } diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index b93c4c3..8abff95 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -3,6 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST + sqlite3_flutter_libs ) list(APPEND FLUTTER_FFI_PLUGIN_LIST