Skip to content

Commit d04c066

Browse files
authored
Merge pull request #1 from Rnbsov/material-theme
🪻 Custom Material Theme 🍃
2 parents c34d2e0 + 3ea7eab commit d04c066

File tree

5 files changed

+554
-20
lines changed

5 files changed

+554
-20
lines changed

lib/main.dart

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import 'package:flutter/material.dart';
2+
import 'util.dart';
3+
import 'theme.dart';
24

35
void main() {
46
runApp(const MyApp());
@@ -10,27 +12,22 @@ class MyApp extends StatelessWidget {
1012
// This widget is the root of your application.
1113
@override
1214
Widget build(BuildContext context) {
15+
final brightness = View.of(context).platformDispatcher.platformBrightness;
16+
17+
// Retrieves the default theme for the platform
18+
//TextTheme textTheme = Theme.of(context).textTheme;
19+
20+
// Use with Google Fonts package to use downloadable fonts
21+
TextTheme textTheme = createTextTheme(
22+
context,
23+
"Roboto Flex",
24+
"Abyssinica SIL",
25+
);
26+
27+
MaterialTheme theme = MaterialTheme(textTheme);
1328
return MaterialApp(
1429
title: 'Flutter Demo',
15-
theme: ThemeData(
16-
// This is the theme of your application.
17-
//
18-
// TRY THIS: Try running your application with "flutter run". You'll see
19-
// the application has a purple toolbar. Then, without quitting the app,
20-
// try changing the seedColor in the colorScheme below to Colors.green
21-
// and then invoke "hot reload" (save your changes or press the "hot
22-
// reload" button in a Flutter-supported IDE, or press "r" if you used
23-
// the command line to start the app).
24-
//
25-
// Notice that the counter didn't reset back to zero; the application
26-
// state is not lost during the reload. To reset the state, use hot
27-
// restart instead.
28-
//
29-
// This works for code too, not just values: Most code changes can be
30-
// tested with just a hot reload.
31-
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
32-
useMaterial3: true,
33-
),
30+
theme: brightness == Brightness.light ? theme.light() : theme.dark(),
3431
home: const MyHomePage(title: 'Flutter Demo Home Page'),
3532
);
3633
}

0 commit comments

Comments
 (0)