如何将Flutter的Scaffold控件改写为支持长尾词的?
- 内容介绍
- 文章标签
- 相关推荐
本文共计1034个文字,预计阅读时间需要5分钟。
Scaffold组件实现了基本的布局结构,包含titlebar、body、侧滑悬浮按钮和底部导航栏。基本应用都会涵盖这些组件。以下是一个示例,包含1个PageView和底部Scaffold,实现了基本的布局结构,包含titlebar、body、侧滑和悬浮按钮。
Scaffold实现了基本的布局结构包含titlebarbody侧滑悬浮按钮bottomNavigationBar,基本用到的都会涵盖。下面是一个例子,包含1.PageView+底Scaffold 实现了基本的布局结构包含titlebar body 侧滑 悬浮按钮 bottomNavigationBar,基本用到的都会涵盖。
下面是一个例子,包含
1. PageView+底部导航栏的联动
2.点击事件
3.标题栏AppBar 菜单项 PopupMenuButton
4.侧滑
5.悬浮按钮
代码如下:
脚手架 Scaffold
import 'package:flutter/material.dart';class LearnScaffold extends StatefulWidget{ @override State createState() { return new _LearnScaffold(); }}class _LearnScaffold extends State{ //标题栏 AppBar getAppBar(){ return new AppBar( backgroundColor: Colors.green,//设置标题栏的背景颜色 title: new Title( child:new Text( '这是一个标题', style: new TextStyle( fontSize: 20.0, color: Colors.white, ), ), color: Colors.white,//设置标题栏文字的颜色(new title的时候color不能为null不然会报错一般可以不用new title 直接new text,不过最终的文字里面还是以里面new text的style样式文字颜色为准) ), centerTitle: true,//设置标题居中 elevation: 10.0,//设置标题栏下面阴影的高度 leading: new Builder( builder: (BuildContext context){ return new GestureDetector(//设置事件 child: new Icon(//设置左边的图标 Icons.account_circle,//设置图标内容 color: Colors.white,//设置图标的颜色 ), onTap:(){ Scaffold.of(context).showSnackBar( new SnackBar(content: new Text('点击')) ); }, onLongPress: (){ Scaffold.of(context).showSnackBar( new SnackBar(content: new Text('长按')) ); }, onDoubleTap: (){ Scaffold.of(context).showSnackBar( new SnackBar(content: new Text('双击')) ); }, ); } ), brightness:Brightness.light,//设置状态栏的字体颜色(白色/黑色) primary: true,//是否设置内容避开状态栏// flexibleSpace: ,//伸缩控件// automaticallyImplyLeading: true, //设置显示在右边的控件 actions: [ new Padding( child: new Icon( Icons.add, color: Colors.white ), padding: EdgeInsets.all(10.0), ), new Padding( child: new Icon( Icons.account_box, color: Colors.white ), padding: EdgeInsets.all(10.0), ), new PopupMenuButton( itemBuilder: (BuildContext context){ return效果图:
本文共计1034个文字,预计阅读时间需要5分钟。
Scaffold组件实现了基本的布局结构,包含titlebar、body、侧滑悬浮按钮和底部导航栏。基本应用都会涵盖这些组件。以下是一个示例,包含1个PageView和底部Scaffold,实现了基本的布局结构,包含titlebar、body、侧滑和悬浮按钮。
Scaffold实现了基本的布局结构包含titlebarbody侧滑悬浮按钮bottomNavigationBar,基本用到的都会涵盖。下面是一个例子,包含1.PageView+底Scaffold 实现了基本的布局结构包含titlebar body 侧滑 悬浮按钮 bottomNavigationBar,基本用到的都会涵盖。
下面是一个例子,包含
1. PageView+底部导航栏的联动
2.点击事件
3.标题栏AppBar 菜单项 PopupMenuButton
4.侧滑
5.悬浮按钮
代码如下:
脚手架 Scaffold
import 'package:flutter/material.dart';class LearnScaffold extends StatefulWidget{ @override State createState() { return new _LearnScaffold(); }}class _LearnScaffold extends State{ //标题栏 AppBar getAppBar(){ return new AppBar( backgroundColor: Colors.green,//设置标题栏的背景颜色 title: new Title( child:new Text( '这是一个标题', style: new TextStyle( fontSize: 20.0, color: Colors.white, ), ), color: Colors.white,//设置标题栏文字的颜色(new title的时候color不能为null不然会报错一般可以不用new title 直接new text,不过最终的文字里面还是以里面new text的style样式文字颜色为准) ), centerTitle: true,//设置标题居中 elevation: 10.0,//设置标题栏下面阴影的高度 leading: new Builder( builder: (BuildContext context){ return new GestureDetector(//设置事件 child: new Icon(//设置左边的图标 Icons.account_circle,//设置图标内容 color: Colors.white,//设置图标的颜色 ), onTap:(){ Scaffold.of(context).showSnackBar( new SnackBar(content: new Text('点击')) ); }, onLongPress: (){ Scaffold.of(context).showSnackBar( new SnackBar(content: new Text('长按')) ); }, onDoubleTap: (){ Scaffold.of(context).showSnackBar( new SnackBar(content: new Text('双击')) ); }, ); } ), brightness:Brightness.light,//设置状态栏的字体颜色(白色/黑色) primary: true,//是否设置内容避开状态栏// flexibleSpace: ,//伸缩控件// automaticallyImplyLeading: true, //设置显示在右边的控件 actions: [ new Padding( child: new Icon( Icons.add, color: Colors.white ), padding: EdgeInsets.all(10.0), ), new Padding( child: new Icon( Icons.account_box, color: Colors.white ), padding: EdgeInsets.all(10.0), ), new PopupMenuButton( itemBuilder: (BuildContext context){ return效果图:

