热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

fullter常用方法

为什么80%的码农都做不了架构师?1.获取屏幕的宽高和状态栏高度doublewidthMediaQuery.of(context).size.widthMedi

为什么80%的码农都做不了架构师?>>>   hot3.png

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");
}

 


转:https://my.oschina.net/woddp/blog/1926753



推荐阅读
author-avatar
清雅竹gf_644
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有