为什么80%的码农都做不了架构师?>>>
1. 获取屏幕的宽高 和状态栏高度
double width=MediaQuery.of(context).size.widthMediaQuery.of(context).padding.top
2. 组件跳转
import 'package:flutter/cupertino.dart';Navigator.of(content).push(new CupertinoPageRoute(builder: (content)=>new EventWidget()),);
3. Container 水平居中
new Align(child: new Container(width: 50.0,height: 50.0,color: Colors.blueAccent,child: new Text(''),),
4. 菊花加载中
return new Container(color: new Color.fromRGBO(244, 245, 245, 1.0),child: new CupertinoActivityIndicator(animating: false,),
);
5. 定时器
import 'dart:async';
Timer.periodic(const Duration(microseconds: 500),(time){print(time);
});
Timer(Duration(microseconds: 500), (){print(_ScrollController.position.maxScrollExtent);_ScrollController.jumpTo(_ScrollController.position.maxScrollExtent+150.0);
});
6. appBar 高度
appBar:PreferredSize(child:new AppBar(backgroundColor: Color.fromRGBO(251, 114, 153, 1.0),title: new Align(child: new Text('分类',style: new TextStyle(color: Colors.white,),),),actions: [new IconButton(icon: new Icon(Icons.file_download,color: Colors.white,),onPressed: null),new IconButton(icon: new Icon(Icons.sms,color: Colors.white,),onPressed: null)],leading: new FlatButton(onPressed: null,child: new Icon(Icons.menu,color: Colors.white,)),
) , preferredSize: Size.fromHeight(48.0)), //设置高度
7. pop 返回 监听
@overridevoid didChangeDependencies() { //会监听Navigator.of(context).pop// TODO: implement didChangeDependenciessuper.didChangeDependencies();print("didChangeDependencies");
}