当前位置:网站首页>MaterialApp
MaterialApp
2022-04-22 08:30:00 【GuoXuan_ CHN】
Flutter API Study
MaterialApp
brief introduction
MaterialApp Express , One APP Using paper and ink design language (Material Design), It contains the basic controls required for the application of paper and ink design style .
Constructors
const MaterialApp({
Key key,
GlobalKey<NavigatorState> navigatorKey,
Widget home,
Map<String, WidgetBuilder> routes: const {},
String initialRoute,
RouteFactory onGenerateRoute,
RouteFactory onUnknownRoute,
List<NavigatorObserver> navigatorObservers: const [],
TransitionBuilder builder,
String title: '',
GenerateAppTitle onGenerateTitle,
Color color,
ThemeData theme,
Locale locale,
Iterable<LocalizationsDelegate> localizationsDelegates,
LocaleListResolutionCallback localeListResolutionCallback,
LocaleResolutionCallback localeResolutionCallback,
Iterable<Locale> supportedLocales: const [Locale('en', 'US')],
bool debugShowMaterialGrid: false,
bool showPerformanceOverlay: false,
bool checkerboardRasterCacheImages: false,
bool checkerboardOffscreenLayers: false,
bool showSemanticsDebugger: false,
bool debugShowCheckedModeBanner: true
})
Constructor parameter description
TransitionBuilder builder
A constructor , Part for inserting navigation , But below WidgetsApp The created part . Or it can be used to replace the navigation .
for example , from BuildContext It's delivered , Such as Directionality,Localizations,DefaultTextStyle,MediaQuery And other methods are feasible . They can also affect all the paths in the navigation in a rewritten way .
This approach is rarely used , But it can be used when you want to change APP Default in . for example , When using English , But use right to left display or overload MediaQuery Indicators to leave blank space for future advertisements to be displayed OEM Code plug-ins .
If you want to override the title to achieve local personalization , Please consider it onGenerateTitle.
builder The callback of is passed through two parameters , One is BuildContext (as context) , One is Navigator widget (as child).
If not used home, routes, onGenerateRoute, or onUnknownRoute To provide rules , be builder There is an obligation to provide rules .
String title
This is not the same as the name of the startup icon , And the current Activity It's a different name . This Title It is used to define the application name seen in the task management window interface . In a native Android Click the circle in the system Home The square button on the right of the button will open the multitask switching window . The application name displayed in the task management window , Namely title
ThemeData theme
Define the theme color used by the app , Defined in paper and ink design primaryColor、accentColor、hintColor Wait for the color value . You can specify a ThemeData Define the color of each control in the application .
Widget home
App Default Components of the path .
Unless initialRoute Property is specified or cannot be displayed normally , be home Is displayed first when the application starts normally .
In order to be able to call directly Theme.of, MediaQuery.of etc. , Can be set at construction time home Parameters , You can use a Builder parts (Builder widget) To obtain a BuildContext
If home Property is specified , be routes Property cannot contain / . because home Replace it with .
If routes Provided , Whether it's through home, routes, onGenerateRoute, or onUnknownRoute, be Navigator It's the only thing built . If not provided , be builder Attribute cannot be null.
In the use of home Properties and builder The difference between attributes is :home The subtree of is inserted in the program Navigator Of ( Both are lower than Overlay). therefore , about home Come on , The dialog box will work automatically ,routes table Will be used , Include Navigator.push and Navigator.pop etc. APIs Will also work as scheduled . By contrast, , from builder The returned control will be placed in Navigator above ( If any ).
String initialRoute
If you build Navigator, Then this is the name of the first displayed line .
The default value is Window.defaultRouteName, But this value may be rewritten by the code that starts the application .
If the route contains slashes , Consider it “ Deep links ”, Before pushing this path , It will also push the path to this path . for example , If the route is /a/b/c, Then the application will start with three routes /a,/a/b and /a/b/c Order of loading .
If any part of this process cannot generate a line , It ignores initialRoute And use Navigator.defaultRouteName(/). If routes Provided , Whether it's through home, routes, onGenerateRoute, or onUnknownRoute, be Navigator It's the only thing built . If not provided , be builder Attribute cannot be null, And initialRoute Not for null.
Color color
The main colors used for applications in the operating system interface .
for example , stay Android On , This is the color used by the application in the application switcher .
Map < String, WidgetBuilder > routes
Top level navigation tables for applications , This is a multi page application used to control page Jump , Similar to the web site , Define page Jump rules in application . The object is a Map<String, WidgetBuilder>.
When using Navigator.pushNamed When it comes to routing , Will be in routes Find route name , Then use the corresponding WidgetBuilder To construct a page switch animation MaterialPageRoute, The container will jump to the new path .
If the application has only one interface , You don't need to set this property , Use home Set up this interface .
If home Not for null, When routes Contained in the Navigator.defaultRouteName(’/’) It's going to go wrong , All two are home The conflict .
If the route you are looking for is routes Does not exist in the , Will pass onGenerateRoute To build the page .
GlobalKey< NavigatorState > navigatorKey
The key used to build the navigator .
If you specify navigatorKry, You can directly operate the navigator , Without having to go through Navigator.of from BuildContext Get navigator , From nacigatorKey, Use GlobalKey.currentState gatter.
If you change this , A new Navigator, Thus, all application states in the process are lost ; under these circumstances , Must also be changed navigatorObservers, Because the previous observer will be attached to the previous navigator .
If onGenerateRoute Not for null, be Navigator Be created . If he is null, be navigatorKey It has to be for null.
List< NavigatorObserver > navigatorObservers
Created for this application Navigator A list of observers .
If changed navigatorKey, You must replace this list with the newly created observer list .
If routes Provided , Whether it's through home, routes, onGenerateRoute, or onUnknownRoute, be Navigator It's the only thing built . If not provided , be navigatorObservers Must be empty list, And builder Not for null.
RouteFactory onGenerateRoute
When App When guided to a named path , Will use this callback function . This is generally used to generate the interface .
When creating a path to handle the specified initialRoute when ,onGenerateRoute return null. Then all paths will be discarded and used Navigator.defaultRouteName.
During normal application operation ,onGenerateRoute The callback will only be pushed after the pathname , And should never return null.
If routes Does not contain the requested line , Use this method .
bool debugShowMaterialGrid
Whether or not shown Paper and ink design Basic layout grid , For debugging UI Tools for
bool showPerformanceOverlay
Show performance labels
bool checkerboardRasterCacheImages
bool showSemanticsDebugger
bool debugShowCheckedModeBanner
Various commissioning switches
remarks
1) Paper and ink design language : namely Material Design, It's a design style guided by Google . On 2018 Google I/O Released Material Design 2.
appreciate
If it helps you , Stand by me , Thank you for

版权声明
本文为[GuoXuan_ CHN]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220735463616.html
边栏推荐
猜你喜欢

nacos基础(4):配置nacos外部数据库

Amino (- NH2) phthalocyanine copper CAS: 28632-30-6 (tetraaminophthalocyanine) copper (II) tetraaminophthalocyanine copper (cutapc) - shared by Qiyue biological editor

ViewPager用法详细解析

原来PID是在老王头和老斯基的斗争中诞生的

The collection palette in LabVIEW 2012 is imported into LabVIEW 2013

nacos基础(3):OPEN API配置管理测试与关闭nacos服务

Nacos Foundation (3): open API configuration management test and close Nacos service

使⽤airtestIDE⽣成脚本,使⽤脚本运⾏

oh-my-notepro

算法--删除链表的倒数第 N 个结点(Kotlin)
随机推荐
sonic云真机入门教程
Under the new retail development trend, how to operate and promote the social e-commerce platform?
I feel that writing a paper is a waste of time. Do I want to write a paper?
QT designer, jump, layout, style
Golang learning, pointer, loop control, correlation
Airtest installation and introduction
One question per day: improve the mold assembly on the 15th day of sprint in the big factory
MySQL深入学习(三一):PowerDesigner的使用
oracle数据库表空间容量查询及扩容
shell脚本中ps -ef查询进程PID一直返回异常
Make the airtest ide into a script and make the script run
新零售发展趋势下,社交电商平台如何运营推广?
机器学习笔记 - 行列式
进程和线程
The integrated optical access equipment provides 16 E1 service ports, 4 100m isolated networks and 2 Gigabit isolated Ethernet optical terminals
vscode的插件
ospf四类,五类和七类LSA详解
Dynamic programming -- lc518 Change II
Goweb Foundation
sql需求处理篇-统计指定某年中有多少个周一至周日