proper theming
This commit is contained in:
parent
f0ca43cf8e
commit
c4e2deb2d7
|
@ -1,43 +1,36 @@
|
||||||
|
import 'package:dynamic_color/dynamic_color.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
runApp(const MyApp());
|
runApp(const App());
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
class App extends StatelessWidget {
|
||||||
const MyApp({super.key});
|
const App({super.key});
|
||||||
|
|
||||||
// This widget is the root of your application.
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MaterialApp(
|
return DynamicColorBuilder(
|
||||||
title: 'Flutter Demo',
|
builder: ((lightDynamic, darkDynamic) => MaterialApp(
|
||||||
theme: ThemeData(
|
title: "HRT",
|
||||||
// This is the theme of your application.
|
theme: ThemeData(
|
||||||
//
|
brightness: Brightness.light,
|
||||||
// TRY THIS: Try running your application with "flutter run". You'll see
|
useMaterial3: true,
|
||||||
// the application has a purple toolbar. Then, without quitting the app,
|
colorScheme: lightDynamic,
|
||||||
// try changing the seedColor in the colorScheme below to Colors.green
|
),
|
||||||
// and then invoke "hot reload" (save your changes or press the "hot
|
darkTheme: ThemeData(
|
||||||
// reload" button in a Flutter-supported IDE, or press "r" if you used
|
brightness: Brightness.dark,
|
||||||
// the command line to start the app).
|
useMaterial3: true,
|
||||||
//
|
colorScheme: darkDynamic,
|
||||||
// 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
|
themeMode: ThemeMode.system,
|
||||||
// restart instead.
|
home: const HomePage(title: "HRT"))),
|
||||||
//
|
|
||||||
// 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'),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyHomePage extends StatefulWidget {
|
class HomePage extends StatefulWidget {
|
||||||
const MyHomePage({super.key, required this.title});
|
const HomePage({super.key, required this.title});
|
||||||
|
|
||||||
// This widget is the home page of your application. It is stateful, meaning
|
// 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
|
// that it has a State object (defined below) that contains fields that affect
|
||||||
|
@ -51,10 +44,10 @@ class MyHomePage extends StatefulWidget {
|
||||||
final String title;
|
final String title;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<MyHomePage> createState() => _MyHomePageState();
|
State<HomePage> createState() => _HomePageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _MyHomePageState extends State<MyHomePage> {
|
class _HomePageState extends State<HomePage> {
|
||||||
int _counter = 0;
|
int _counter = 0;
|
||||||
|
|
||||||
void _incrementCounter() {
|
void _incrementCounter() {
|
||||||
|
|
|
@ -49,6 +49,14 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.6"
|
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:
|
fake_async:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -186,3 +194,4 @@ packages:
|
||||||
version: "0.1.4-beta"
|
version: "0.1.4-beta"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=3.2.0-134.1.beta <4.0.0"
|
dart: ">=3.2.0-134.1.beta <4.0.0"
|
||||||
|
flutter: ">=3.4.0-17.0.pre"
|
||||||
|
|
|
@ -35,6 +35,7 @@ dependencies:
|
||||||
# The following adds the Cupertino Icons font to your application.
|
# The following adds the Cupertino Icons font to your application.
|
||||||
# Use with the CupertinoIcons class for iOS style icons.
|
# Use with the CupertinoIcons class for iOS style icons.
|
||||||
cupertino_icons: ^1.0.2
|
cupertino_icons: ^1.0.2
|
||||||
|
dynamic_color: ^1.6.7
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|
|
@ -13,7 +13,7 @@ import 'package:hrt/main.dart';
|
||||||
void main() {
|
void main() {
|
||||||
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
|
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
|
||||||
// Build our app and trigger a frame.
|
// Build our app and trigger a frame.
|
||||||
await tester.pumpWidget(const MyApp());
|
await tester.pumpWidget(const App());
|
||||||
|
|
||||||
// Verify that our counter starts at 0.
|
// Verify that our counter starts at 0.
|
||||||
expect(find.text('0'), findsOneWidget);
|
expect(find.text('0'), findsOneWidget);
|
||||||
|
|
Loading…
Reference in a new issue