-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmy_app.dart
30 lines (26 loc) · 892 Bytes
/
my_app.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// 5. 使用 AppThemeProvider 包裹你的 Widget 树,并提供主题数据
import 'package:flutter/material.dart';
import 'package:flutter_samples/InheritedWidget/app_theme_data.dart';
import 'package:flutter_samples/InheritedWidget/app_theme_provider.dart';
import 'package:flutter_samples/InheritedWidget/my_home_page.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
// 定义你的主题数据
final appTheme = AppThemeData(
primaryColor: Colors.blue,
textStyle: const TextStyle(fontSize: 16, color: Colors.black87),
);
return AppThemeProvider(
themeData: appTheme, // 提供主题数据
child: MaterialApp(
title: 'InheritedWidget Theme Demo',
home: const MyHomePage(),
),
);
}
}