diff --git a/lib/main.dart b/lib/main.dart index 447ad25..0c92307 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -6,6 +6,7 @@ import 'dart:async'; import 'dart:io'; import 'package:sqflite_common_ffi/sqflite_ffi.dart'; //for testing on desktop import 'utilities.dart'; +import 'package:dynamic_color/dynamic_color.dart'; void main() async { await dotenv.load(); @@ -18,29 +19,34 @@ void main() async { runApp(const MyApp()); } +final _defaultLightScheme = ColorScheme.fromSeed(seedColor: Colors.yellow); +final _defaultDarkScheme = ColorScheme.fromSeed( + seedColor: Colors.yellow, + brightness: Brightness.dark, +); + class MyApp extends StatelessWidget { const MyApp({super.key}); // This widget is the root of your application. @override Widget build(BuildContext context) { - return MaterialApp( - title: 'Oeffimaster', - theme: ThemeData( - brightness: Brightness.light, - colorSchemeSeed: Colors.yellow, - ), - darkTheme: ThemeData( - brightness: Brightness.dark, - colorSchemeSeed: Colors.yellow, - ), - themeMode: ThemeMode.system, - // home: const MyHomePage(title: 'Oeffimaster'), //this is what matters - home: const JourneyOverviewPage(), - // routes: { - // //'/': (context) => const MyHomePage(title: 'Oeffimaster'), - // '/stations': (context) => const ChooseStationPage(), - // }, + return DynamicColorBuilder( + builder: (ColorScheme? lightDynamic, ColorScheme? darkDynamic) { + return MaterialApp( + theme: ThemeData( + useMaterial3: true, + colorScheme: lightDynamic ?? _defaultLightScheme, + ), + darkTheme: ThemeData( + useMaterial3: true, + colorScheme: darkDynamic ?? _defaultDarkScheme, + ), + themeMode: ThemeMode.system, + home: const JourneyOverviewPage(), + title: 'Oeffimaster', + ); + }, ); } } diff --git a/pubspec.lock b/pubspec.lock index 43f988f..53a4fc8 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -65,6 +65,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.9" + dynamic_color: + dependency: "direct main" + description: + name: dynamic_color + sha256: "4aeb76de323e8eb660bab5557d826ad7ebbf1434a598f0c6aa8a11a9696a6757" + url: "https://pub.dev" + source: hosted + version: "1.9.0" fake_async: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 82c7681..9737a63 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -39,6 +39,7 @@ dependencies: sqflite: ^2.4.2+1 sqlite3: ^3.3.0 sqflite_common_ffi: ^2.4.0+3 + dynamic_color: ^1.9.0 dev_dependencies: flutter_test: sdk: flutter