首页
统计
墙纸
留言
Search
1
PVE8优化
19 阅读
2
mysql创建数据库
12 阅读
3
jenkins根据分支、文件夹打包
12 阅读
4
vue-cli注册全局方法
7 阅读
5
开心的加班
7 阅读
web前端
Vue
CSS
javascript
React
那些年爬过过的坑
ES6
TypeScrippt
ES7
javascript图灵 - 总结
Node
面试总结
React-Native
Web优化
基础
AngularJS
拍摄
Flutter
Dart
Docker
Linux
mysql
PVE
登录
/
注册
Search
标签搜索
vue+elementui
Cicaba
累计撰写
146
篇文章
累计收到
13
条评论
首页
栏目
web前端
Vue
CSS
javascript
React
那些年爬过过的坑
ES6
TypeScrippt
ES7
javascript图灵 - 总结
Node
面试总结
React-Native
Web优化
基础
AngularJS
拍摄
Flutter
Dart
Docker
Linux
mysql
PVE
页面
统计
墙纸
留言
搜索到
2
篇与
的结果
2020-03-10
Flutter MaterialApp - Scaffold - DefaultTabController - AppBar
class App extends StatelessWidget { @override //重写父类 Widget build(BuildContext context) { return MaterialApp( //Material风格app debugShowCheckedModeBanner: false, //关闭状态栏debug home: Home(), theme: ThemeData( //主题 primaryColor: color(0x0075b8), //主题颜色 highlightColor: color(0xffffff, a: 0.4), //高亮颜色 splashColor: color(0xffffff, a: 0.6), //水波颜色 ), ); } } class Home extends StatelessWidget { @override Widget build(BuildContext context) { return DefaultTabController( //TabBar和TabBarView的控制器,它是关联这两个组件的桥梁 length: 3, child: Scaffold( //脚手架组件 appBar: AppBar( //显示在界面顶部的一个AppBar title: Center( child: Text( "首页", style: TextStyle( fontSize: 20, fontWeight: FontWeight.w900, color: color(0xffffff), ), ), ), leading: IconButton( //标题前面显示的一个组件 icon: Icon(Icons.menu), tooltip: "Navigration", onPressed: () => debugPrint("Navigration"), ), actions: <Widget>[ //一个Widget列表一般放按钮 IconButton( icon: Icon(Icons.search), tooltip: "search", onPressed: () => debugPrint("search"), ) ], elevation: 4, //bar阴影默认4 bottom: TabBar( //ab页的选项组件,默认为水平排列。 unselectedLabelColor: color(0xffffff, a: 0.5), indicatorColor: color(0xffffff), indicatorSize: TabBarIndicatorSize.label, indicatorWeight: 2, tabs: <Widget>[ //Tab选项列表 Tab(icon: Icon(Icons.local_florist)), Tab(icon: Icon(Icons.change_history)), Tab(icon: Icon(Icons.directions_bike)), ], ), ), body: TabBarView( //ab页的内容容器,Tab页内容一般处理为随选项卡的改变而改变 children: <Widget>[ Icon(Icons.local_florist, size: 100, color: color(0x0075b8)), Icon(Icons.change_history, size: 100, color: color(0x0075b8)), Icon(Icons.directions_bike, size: 100, color: color(0x0075b8)), ], ), bottomNavigationBar: BottomBar()), ), ); } } class _BottomBar extends State<BottomBar> { int _currentIndex = 0; void _bottomTap(int index) { setState(() { _currentIndex = index; }); } @override Widget build(BuildContext context) { return BottomNavigationBar( type: BottomNavigationBarType.fixed, selectedItemColor: color(0x00000), unselectedItemColor: color(0x999999), currentIndex: _currentIndex, onTap: _bottomTap, items: [ BottomNavigationBarItem( icon: Icon(Icons.home), title: Text("home"), ), BottomNavigationBarItem( icon: Icon(Icons.domain), title: Text("domain"), ), BottomNavigationBarItem( icon: Icon(Icons.people_outline), title: Text("people_outline"), ), ], ); } } Color color(int rgb, {double a = 1}) { if (a < 0) { a = 0; } else if (a > 1) { a = 1; } return Color.fromRGBO( (rgb & 0xFF0000) >> 16, (rgb & 0x00FF00) >> 8, (rgb & 0x0000FF) >> 0, a, ); }
2020年03月10日
2 阅读
0 评论
0 点赞
2019-04-03
Dart基础一
一、常量与变量运算符:~/ 取整赋值运算符: ??= 无值赋值常用属性:isNaN(是否是非数字)、isEven(是否是偶数)、isOdd(是否是奇数常用方法:abs()(取绝对值)、round()(四舍五入)、floor()(大于它的最小整数)、ceil()(小于它的最大整数)、toInt()(变成整型)、toDouble()(变成浮点型)二、字符串字符串创建:可以使用三个单引号或者三个双引号创建多行字符串、使用r创建raw原始的字符串.字符串操作:字符串也可以进行+ * == [],分别为字符串相加,乘以倍数,是否相等,取某个字符.插值表达式:${expression}常用属性:length、isEmpty、isNotEmpty常用方法:三、布尔型表示:bool四、ListList中的元素可以是有不同的类型创建List :var list=[1,2,3];创建不可变得List:var list = const[1,2,3]构造创建:var list=new List();//在dart2 中已经去掉了new关键字五、Map创建map:var user={"name":"zoey","age":18}创建不可变的map:var user=const {"name":"zoey","age":18}构造创建var user=new Map();var map1={"first":"dart",1:true};//key还可以不是字符串??六、dynamic可以理解为泛型七、关系运算符判断内容是否相同使用==,而在java中==表示的是判断两个引用是否相等,判断内容相当用的是equals八、可选参数可选命名参数:{param1,param2,...}必填的参数不用写参数名,可选的参数必须要写参数名,而且可以跳过一些参数,不按顺序传,只要参数名对得上就可以了,这种方式用得比较多可选位置参数:[param1,param2,...]根据参数的位置,默认的进行传参,但不能跳过某个参数可选参数必须在必选参数后面八、构造函数当想在对象上执行多个操作时可以使用级联操作符(..)//链式调用私有属性使用(_)开头实例变量: 如果在定义实例变量时设置它的值,而不是在构造函数或其他函数中赋值,则赋值操作发生在构造函数和初始化列表执行之前如果父类没有无名无参数的默认构造函数,则子类必须手动调用一个父类构造函数。在:后面构造函数体之前指定要调用的父类构造函数class Person { Person.fromJson(Map data) { print('in Person'); } } class Employee extends Person { // Person 没有默认构造函数 // 所以必需指定 super.fromJson(data) 构造函数 Employee.fromJson(Map data) : super.fromJson(data) { print('in Employee'); } }重定向构造函数: 有些构造函数只是调用同一个类中的另外一个构造函数class Point { num x; num y; Point(this.x, this.y); // 该类的主要构造函数 Point.alongXAxis(num x) : this(x, 0); // 调用主要构造函数 }常量构造函数: 如果类生成从来不改变的对象,则可以把这些对象定义为编译器常量。用一个const构造函数赋值为实例变量,并将实例变量设置为final来实现class ImmutablePoint { final num x; final num y; const ImmutablePoint(this.x, this.y); static final ImmutablePoint origin = const ImmutablePoint(0, 0); }工厂构造函数: 如果一个构造函数并不总是要创建新的对象(或从缓存中返回实例),可以用factory关键字修饰构造函数class Logger { final String name; bool mute = false; // _cache is library-private, thanks to the _ in front of its name. static final Map<String, Logger> _cache = <String, Logger>{}; factory Logger(String name) { if (_cache.containsKey(name)) { return _cache[name]; } else { final logger = new Logger._internal(name); _cache[name] = logger; return logger; } } Logger._internal(this.name); void log(String msg) { if (!mute) { print(msg); } } }九、类型测试操作符操作符 描述as Typecase(类型转换)is 如果对象是该类型,则返回trueis! 如果对象是该类型,则返回falseassert语句只在检测模式下有效,在生产模式下无任何效果使用assert语句检测执行条件。如果条件是false,则中断执行并抛出异常(AssertionError)
2019年04月03日
5 阅读
0 评论
0 点赞