proper theming

main
Lea 2023-09-23 22:01:51 +02:00
parent f0ca43cf8e
commit c4e2deb2d7
Signed by: Lea
GPG Key ID: 1BAFFE8347019C42
4 changed files with 34 additions and 31 deletions

View File

@ -1,43 +1,36 @@
import 'package:dynamic_color/dynamic_color.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
runApp(const App());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
class App extends StatelessWidget {
const App({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// TRY THIS: Try running your application with "flutter run". You'll see
// the application has a purple toolbar. Then, without quitting the app,
// try changing the seedColor in the colorScheme below to Colors.green
// and then invoke "hot reload" (save your changes or press the "hot
// reload" button in a Flutter-supported IDE, or press "r" if you used
// the command line to start the app).
//
// Notice that the counter didn't reset back to zero; the application
// state is not lost during the reload. To reset the state, use hot
// restart instead.
//
// This works for code too, not just values: Most code changes can be
// tested with just a hot reload.
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
return DynamicColorBuilder(
builder: ((lightDynamic, darkDynamic) => MaterialApp(
title: "HRT",
theme: ThemeData(
brightness: Brightness.light,
useMaterial3: true,
colorScheme: lightDynamic,
),
darkTheme: ThemeData(
brightness: Brightness.dark,
useMaterial3: true,
colorScheme: darkDynamic,
),
themeMode: ThemeMode.system,
home: const HomePage(title: "HRT"))),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
class HomePage extends StatefulWidget {
const HomePage({super.key, required this.title});
// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
@ -51,10 +44,10 @@ class MyHomePage extends StatefulWidget {
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
State<HomePage> createState() => _HomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
class _HomePageState extends State<HomePage> {
int _counter = 0;
void _incrementCounter() {

View File

@ -49,6 +49,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.6"
dynamic_color:
dependency: "direct main"
description:
name: dynamic_color
sha256: "96bff3df72e3d428bda2b874c7a521e8c86f592cae626ea594922fcc8d166e0c"
url: "https://pub.dev"
source: hosted
version: "1.6.7"
fake_async:
dependency: transitive
description:
@ -186,3 +194,4 @@ packages:
version: "0.1.4-beta"
sdks:
dart: ">=3.2.0-134.1.beta <4.0.0"
flutter: ">=3.4.0-17.0.pre"

View File

@ -35,6 +35,7 @@ dependencies:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
dynamic_color: ^1.6.7
dev_dependencies:
flutter_test:

View File

@ -13,7 +13,7 @@ import 'package:hrt/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(const MyApp());
await tester.pumpWidget(const App());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);