当前位置:网站首页>flutter系列之:Material主题的基础-MaterialApp
flutter系列之:Material主题的基础-MaterialApp
2022-06-09 15:48:00 【InfoQ】
简介
MaterialApp初探
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
)
}
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: const <Widget>[
Text(
'home page',
),
],
),
),
);

MaterialApp详解
class MaterialApp extends StatefulWidget
MaterialApp中的theme
final ThemeData? theme;
final ThemeData? darkTheme;
final ThemeData? highContrastTheme;
final ThemeData? highContrastDarkTheme;
final ThemeMode? themeMode;
MaterialApp中的routes
routes: <String, WidgetBuilder> {
'/a': (BuildContext context) => MyPage(title: 'page A'),
'/b': (BuildContext context) => MyPage(title: 'page B'),
'/c': (BuildContext context) => MyPage(title: 'page C'),
},
Navigator.push(context, MaterialPageRoute<void>(
builder: (BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('My Page')),
body: Center(
child: TextButton(
child: Text('POP'),
onPressed: () {
Navigator.pop(context);
},
),
),
);
},
));
Navigator.pop(context);
/MaterialApp中的locale
const Locale swissFrench = Locale('fr', 'CH');
const Locale canadianFrench = Locale('fr', 'CA');
MaterialApp(
localizationsDelegates: [
// ... app-specific localization delegate[s] here
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
],
supportedLocales: [
const Locale('en', 'US'), // English
const Locale('he', 'IL'), // Hebrew
// ... other locales the app supports
],
// ...
)
MaterialApp和WidgetsApp
return ScrollConfiguration(
behavior: widget.scrollBehavior ?? const MaterialScrollBehavior(),
child: HeroControllerScope(
controller: _heroController,
child: result,
),
);
总结
边栏推荐
- R语言使用aov函数进行双因素方差分析(Two-way factorial ANOVA)、gplots包的plotmeans函数在双因素方差分析中显示交互作用、包括均值,误差条、95%置信区间、样本量
- 65 2D drawing (basic drawing and filling)
- 五月集训(第31天) —— 状态压缩
- Analysis of variable hiding security in contract security
- R language ggplot2 visualization: using stat_ The summary function adds the number of samples to the results of the ggplot2 visual image (stat_summary to annotate plot sample number)
- June training (day 03) - sorting
- 64 界面外观(窗口无边框,不规则窗体,透明窗体)
- 70 DOM reading XML
- "CSDN powder raising strategy" 11 powder raising methods, how many have you learned?
- 中途离开电脑怎么一键锁屏
猜你喜欢

LeetCode 327. 区间和的个数
![[SEETF]Super Secure Requests Forwarder](/img/b4/f3211c28a2474973e231a69d9a4ca8.png)
[SEETF]Super Secure Requests Forwarder

The aquatic industry digital B2B e-commerce platform realizes fine management and drives enterprise performance growth

记一次可怜的150元RCE平安Src挖掘

一个时代的终结!吴恩达经典《机器学习》课程本月关闭注册...然而

Experience sharing of technical we media realization -- starting to try to make CSDN's reply one year later

The interviewer asked me how many locks were added to an update statement? I summarized the whole eight part essay

Problem with the setting of working directory when GoLand runs the Go program: an error path is reported. If no such file or directory is not found, check the configuration

Build an integrated intelligent dialogue analysis platform from intelligent quality inspection to dialogue analysis, and the customer service center of Bank of Hangzhou creates a new business card of

Dapr source code analysis | basic introduction
随机推荐
五月集训(第24天) —— 线段树
Customizing the in app keyboard in fluent
Analysis of folder Writeability during SAP commerce cloud construction
枚举的替代方案 —— 枚举类
R language ggplot2 visualization: using stat_ The summary function adds the number of samples to the results of the ggplot2 visual image (stat_summary to annotate plot sample number)
Kubernetes core concepts
virtualBox 虚拟机网卡设置
R语言ggplot2可视化:使用stat_summary函数在ggplot2可视化图像的结果中添加样本个数信息(stat_summary to annotate plot sample number)
还在从零开始搭建项目?这款升级版快速开发脚手架值得一试~
The aquatic industry digital B2B e-commerce platform realizes fine management and drives enterprise performance growth
Kubernetes certificate collection
10个必备的AutoCAD插件
R language uses AOV function to perform two-way factorial ANOVA, and the plotmeans function of gplots package displays interaction in two-way ANOVA, including mean, error bar, 95% confidence interval
六月集训(第06天) —— 滑动窗口
站长工具浏览器SEO插件-站长必备工具 SEO网站排名 快速查看网站数据
单体应用和微服务调用区别
Byte side: how to check if the website cannot be displayed?
June training (day 03) - sorting
Dapr source code analysis | project overview
May training (day 23) - dictionary tree