/ lib / main.dart
main.dart
 1  import 'package:adaptive_theme/adaptive_theme.dart';
 2  import 'package:flutter/material.dart';
 3  import 'views/maze.dart';
 4  
 5  /**
 6  * This helper-method provides a way to generate the theme-data for the app in
 7  * a way which is consistent between light and dark modes.
 8  */
 9  TextTheme _generateTheme(Color fontColor) {
10  	return TextTheme(
11  		headline1: TextStyle(
12  			color: fontColor, fontSize: 28, fontWeight: FontWeight.bold
13  		),
14  		headline2: TextStyle(
15  			color: fontColor,
16  			fontSize: 22,
17  			decoration: TextDecoration.underline,
18  			fontWeight: FontWeight.bold
19  		),
20  		headline3: TextStyle(color: fontColor, fontSize: 22),
21  		headline4: TextStyle(
22  			color: fontColor, fontSize: 18, fontWeight: FontWeight.bold
23  		),
24  		headline5: TextStyle(color: fontColor, fontSize: 18)
25  	);
26  }
27  
28  class MyApp extends StatelessWidget {
29  	const MyApp({Key? key}) : super(key: key);
30  
31  	// This widget is the root of your application.
32  	@override
33  	Widget build(BuildContext context) {
34  		// Set the title of the application's home page:
35  		final title = 'A-Maze';
36  
37  		// Use the `AdaptiveTheme` library to allow the theme to be
38  		// transitioned between dark and light mode while the app is in use.
39  		return AdaptiveTheme(
40  			builder: (theme, darkTheme) {
41  				return MaterialApp(
42  					title: title,
43  					theme: theme,
44  					darkTheme: darkTheme,
45  					// Show the HomePage widget by default:
46  					home: MazeView(title: title)
47  				);
48  			},
49  			dark: ThemeData(
50  				brightness: Brightness.dark,
51  				primarySwatch: Colors.yellow,
52  				textTheme: _generateTheme(Colors.white)
53  			),
54  			initial: AdaptiveThemeMode.dark,
55  			light: ThemeData(
56  				brightness: Brightness.light,
57  				primarySwatch: Colors.yellow,
58  				textTheme: _generateTheme(Colors.black)
59  			)
60  		);
61  	}
62  }
63  
64  void main() {
65  	runApp(const MyApp());
66  }