mirror of
https://github.com/kuhyx/todo-app.git
synced 2026-11-11 13:27:46 +01:00
Standardizes on the same stricter lint set + shared analysis_options.yaml used by diet-guard/app and the new habit_stack app. Fixes all 127 issues surfaced: dart fix --apply for imports/cascades/sorting, unawaited() on fire-and-forget Futures, bare catch(e) narrowed to on Exception catch(e) (matching diet_guard's existing pattern), one documented ignore for a deliberate TypeError catch around untrusted peer JSON, and missing public-member doc comments throughout. No behavior change: 174/174 tests pass, 100% line coverage maintained. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
52 lines
1.7 KiB
Dart
52 lines
1.7 KiB
Dart
// coverage:ignore-file
|
|
// App bootstrap: wires platform DB paths (path_provider) into the repository
|
|
// and calls runApp. Exercised end-to-end by running the app, not unit tests.
|
|
import 'dart:io';
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:path/path.dart' as p;
|
|
import 'package:path_provider/path_provider.dart';
|
|
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
|
|
|
|
import 'package:todo/data/note_repository.dart';
|
|
import 'package:todo/ui/capture_screen.dart';
|
|
|
|
Future<void> main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
// Desktop platforms need the FFI sqlite implementation initialised
|
|
// before any database is opened; mobile uses the bundled library.
|
|
if (!kIsWeb && (Platform.isLinux || Platform.isWindows || Platform.isMacOS)) {
|
|
sqfliteFfiInit();
|
|
}
|
|
|
|
final dir = await getApplicationSupportDirectory();
|
|
final dbPath = p.join(dir.path, 'todo.db');
|
|
final repository = await NoteRepository.open(dbPath);
|
|
|
|
runApp(TodoApp(repository: repository));
|
|
}
|
|
|
|
/// Root widget. Holds the single [NoteRepository] instance and hands it
|
|
/// to the screens that need it.
|
|
class TodoApp extends StatelessWidget {
|
|
/// Creates a [TodoApp] wrapping the given [repository].
|
|
const TodoApp({required this.repository, super.key});
|
|
|
|
/// The single, app-wide note store, injected into every screen.
|
|
final NoteRepository repository;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp(
|
|
title: 'todo',
|
|
theme: ThemeData(
|
|
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
|
|
useMaterial3: true,
|
|
),
|
|
home: CaptureScreen(repository: repository),
|
|
);
|
|
}
|
|
}
|