//获取设备宽度MediaQuery.of(context).size.width
column宽度问题
//使用占满crossAxisAlignment:CrossAxisAlignment.stretch,
padding
//垂直水平EdgeInsets.symmetric(vertical:10,horizontal:18)//指定方向EdgeInsets.only(left:10,right:5,top:1,bottom:4)//所有方向EdgeInsets.all(10)
布局
//自动换行Wrap//布局容器Container//垂直排列Column//水平排列Row
自适应
/// pubspec.yaml加入flutter_screenutil: ^0.4.0///在build下初始化设计稿大小ScreenUtil.instance =ScreenUtil(width: 1080,height: 1920)..init(context);///自适应字体大小ScreenUtil().setSp()///自适应宽度ScreenUtil().setWidth()///自适应高度ScreenUtil().setHeight()
修改appbar高度
// PreferredSize包住AppBarPreferredSize(child: AppBar(// Here we take the value from the MyHomePage object that was created by// the App.build method, and use it to set our appbar title.title: Text( widget.title,style: new TextStyle(fontSize: ScreenUtil().setSp(42)), ),centerTitle: true,backgroundColor: Colors.deepOrangeAccent, ),preferredSize: Size.fromHeight(45) )
事件
new GestureDetector(onTap: () { Navigator.of(context).pushNamed(route);} )
Widget初始化参数
constKSwiper({this.skey =''}) :super();finalStringskey;//其中KSwiper和类名相同;
TextField不能直接放Row
使用Expanded包裹住就可以了
圆角
Container(width: Screen.width(300),padding: EdgeInsets.all(16),alignment: Alignment.center,decoration: BoxDecoration(color: Colors.white,shape: BoxShape.circle ),child: Image.asset('assets/images/logo.png'),)
让手机号输入框获得焦点
FocusNode phoneFocus =newFocusNode();FocusScope.of(context).requestFocus(this.phoneFocus);
安全区域布局(内容不会显示在状态栏)
SafeArea(child: SafeArea.expand(child: Container() ))
Textfield键盘类型
keyboardType:TextInputType.phone,
Textfield的placeholder
decoration: InputDecoration(hintText:'请输入验证码',)
原文:https://note.youdao.com/ynoteshare1/index.html?id=d4929d98c31d058f4cf3e399e291c65c&type=note










网友评论