feat: set up Flutter project with drift database, Riverpod providers, and LLM service layer
- Configure dependencies: drift 2.32.x, flutter_riverpod 3.3.1, fl_chart 1.2.x, flutter_local_notifications 21.x, local_auth 3.x, and supporting packages - Drop riverpod_generator (incompatible analyzer version with drift_dev 2.32.x); convert all providers to manual Riverpod 3.x API using Notifier<T> and typed families - Define drift schema: MoodEntries, Activities, EntryActivities, Tags, EntryTags, LlmInsights, UserSettings with four DAOs (mood, activity, insight, settings) - Add LLM service abstraction (LlmService) and MediaPipe implementation - Fix SettingsDao.delete → deleteByKey to avoid shadowing drift's inherited delete method
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
import 'package:drift/drift.dart';
|
||||
import 'package:drift_flutter/drift_flutter.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
import 'tables.dart';
|
||||
import 'daos/mood_dao.dart';
|
||||
import 'daos/activity_dao.dart';
|
||||
import 'daos/insight_dao.dart';
|
||||
import 'daos/settings_dao.dart';
|
||||
|
||||
part 'app_database.g.dart';
|
||||
|
||||
@DriftDatabase(
|
||||
tables: [
|
||||
MoodEntries,
|
||||
Activities,
|
||||
EntryActivities,
|
||||
Tags,
|
||||
EntryTags,
|
||||
LlmInsights,
|
||||
UserSettings,
|
||||
],
|
||||
daos: [
|
||||
MoodDao,
|
||||
ActivityDao,
|
||||
InsightDao,
|
||||
SettingsDao,
|
||||
],
|
||||
)
|
||||
class AppDatabase extends _$AppDatabase {
|
||||
AppDatabase() : super(_openConnection());
|
||||
|
||||
@override
|
||||
int get schemaVersion => 1;
|
||||
|
||||
@override
|
||||
MigrationStrategy get migration => MigrationStrategy(
|
||||
onCreate: (m) async {
|
||||
await m.createAll();
|
||||
await _seedDefaultActivities();
|
||||
},
|
||||
onUpgrade: (m, from, to) async {
|
||||
// Future migrations go here
|
||||
},
|
||||
);
|
||||
|
||||
Future<void> _seedDefaultActivities() async {
|
||||
final defaults = [
|
||||
(
|
||||
name: 'Exercise',
|
||||
icon: 0xe567,
|
||||
colour: '#FF6B6B'
|
||||
), // Icons.fitness_center
|
||||
(name: 'Good sleep', icon: 0xe7f5, colour: '#7B68EE'), // Icons.bedtime
|
||||
(name: 'Social', icon: 0xe7ef, colour: '#FFB347'), // Icons.people
|
||||
(name: 'Work', icon: 0xe8b6, colour: '#4FC3F7'), // Icons.work
|
||||
(name: 'Food', icon: 0xe56c, colour: '#81C784'), // Icons.restaurant
|
||||
(name: 'Reading', icon: 0xe865, colour: '#F06292'), // Icons.menu_book
|
||||
(name: 'Outdoors', icon: 0xe1a1, colour: '#AED581'), // Icons.park
|
||||
(
|
||||
name: 'Family',
|
||||
icon: 0xe8a1,
|
||||
colour: '#FFD54F'
|
||||
), // Icons.family_restroom
|
||||
(
|
||||
name: 'Meditation',
|
||||
icon: 0xe7fb,
|
||||
colour: '#80CBC4'
|
||||
), // Icons.self_improvement
|
||||
(name: 'Travel', icon: 0xe8b5, colour: '#FF8A65'), // Icons.flight
|
||||
];
|
||||
|
||||
for (final (index, a) in defaults.indexed) {
|
||||
await into(activities).insert(
|
||||
ActivitiesCompanion.insert(
|
||||
name: a.name,
|
||||
iconCodepoint: a.icon,
|
||||
colourHex: a.colour,
|
||||
sortOrder: Value(index),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QueryExecutor _openConnection() {
|
||||
return driftDatabase(
|
||||
name: 'lumina_db',
|
||||
native: DriftNativeOptions(
|
||||
databaseDirectory: getApplicationSupportDirectory,
|
||||
),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user