前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Flutter基础widgets教程-WidgetsApp篇

Flutter基础widgets教程-WidgetsApp篇

原创
作者头像
青年码农
发布2020-10-10 17:23:55
5580
发布2020-10-10 17:23:55
举报
文章被收录于专栏:青年码农

1 WidgetsApp

未经过改装的MaterialApp 可以说MaterialApp基于WidgetsApp

2 构造函数

代码语言:javascript
复制
MaterialApp({
  Key key,
  this.title = '', 
  this.home,
  this.color, 
  this.textStyle
  this.theme, 
  this.routes = const <String, WidgetBuilder>{}, 
  this.navigatorKey, 
  this.initialRoute, 
  this.onGenerateRoute, 
  this.onUnknownRoute, 
  this.navigatorObservers = const <NavigatorObserver>[], 
  this.builder, 
  this.onGenerateTitle, 
  this.locale, 
  this.localizationsDelegates, 
  this.localeListResolutionCallback, 
  this.localeResolutionCallback, 
  this.supportedLocales = const <Locale>Locale('en', 'US'), 
  this.debugShowMaterialGrid = false, 
  this.showPerformanceOverlay = false, 
  this.checkerboardRasterCacheImages = false, 
  this.checkerboardOffscreenLayers = false, 
  this.showSemanticsDebugger = false,
  this.debugShowCheckedModeBanner = true, 
  this.debugShowWidgetInspector
}) 

3 常用属性

3.1 title:安卓手机任务管理页面所看到应用的名字

代码语言:javascript
复制
title:Text("Flutter Demo"),

3.2 home:app运行时打开的首页面

代码语言:javascript
复制
home: MyApp(),

3.3 routes:定义路由

内容为map健值对;key为路由名称,value为路由对应的页面。页面需要跳转时,可以通过Navigator.pushNamed(context, 'rooteName');来跳转,

3.4 theme:定义主题

代码语言:javascript
复制
theme: ThemeData(
    primaryColor: Colors.red,
),

3.5 debugShowWidgetInspector

当为true时,打开检查覆盖,该字段只能在检查模式下可用

3.6 inspectorSelectButtonBuilder

构建一个视图与视图切换的小部件,可以通过该小部件或按钮切换到检查模式(debugShowWidgetInspector==true时才有效,点击该按钮之后再点击你要检查的视图)

3.7 debugShowMaterialGrid

该字段开启后,会在WidgetsApp外层包裹GridPaper,这个部件主要显示网格

3.8 initialRoute

指定默认显示的路由名字,默认值为 Window.defaultRouteName

3.9 onGenerateRoute

路由回调函数

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1 WidgetsApp
  • 2 构造函数
  • 3 常用属性
    • 3.1 title:安卓手机任务管理页面所看到应用的名字
      • 3.2 home:app运行时打开的首页面
        • 3.3 routes:定义路由
          • 3.4 theme:定义主题
            • 3.5 debugShowWidgetInspector
              • 3.6 inspectorSelectButtonBuilder
                • 3.7 debugShowMaterialGrid
                  • 3.8 initialRoute
                    • 3.9 onGenerateRoute
                    领券
                    问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档