flutter 更改主题颜色
在 main.js 中
| GetMaterialApp( ... theme: ThemeData( colorScheme: const ColorScheme.light().copyWith(primary: Color.fromRGBO(255, 255, 255, 1)), ), ... ), |
更改状态栏颜色
同样在 main.js 中
| void main(){ SystemUiOverlayStyle systemUiOverlayStyle = const SystemUiOverlayStyle( statusBarColor:Color.fromRGBO(255, 255, 255, 1)), statusBarIconBrightness: Brightness.light, ); SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle); runApp(...); } |
表单样式配置
| TextField( maxLines: 1, decoration: InputDecoration( hintText: "搜索", hintStyle:TextStyle(color:Color.fromRGBO(206, 206, 206, 1)), contentPadding: EdgeInsets.symmetric(vertical:9,horizontal:-10), border: InputBorder.none, icon:Padding( padding: EdgeInsets.only(left: 10,), child: Icon( Icons.search, color: Color.fromRGBO(228, 228, 228, 1), ), ) ), ), |
获取状态栏的高度
| MediaQuery.of(context).padding.top |
宽度填满元素
| MediaQuery. of (context).size.width |
点击交互水波浪改圆角
| Inkell( |
| borderRadius: BorderRadius.circular(20), |
| onTap:(){}, |
| child:Widget |
| ) |
Ink 组件配置水波纹
场景重现:如果 Inkell 的子集元素设置了背景颜色,默认的水波纹将会消失,例如下面的代码
| InkWell( child:Container( decoration:BoxDecoration( color:Colors.red ), child:Text("按钮") ) ) |
解决方式:使用 Ink
组件嵌套 InkWell
, 可以出现水波纹效果,使用同 Container
一致
| Ink( decoration: BoxDecoration( color: MyTheme.themeColor, borderRadius: BorderRadius.circular(20) ), child:InkWell( onTap(){}, child:Container( child:Text("按钮") ) ) ) |
flutter 进度条
线性进度条
|
body:LinearProgressIndicator(value:0.4), |
环形进度
| body:CircularProgressIndicator(value:0.4) |
container 组件添加阴影
| Container( decoration:BocDecoration( boxShadow: const[ BoxShadow( color: Colors.black12, offset: Offset(0.0, 0.0), blurRadius: 4.0, spreadRadius:1.0 ) ] ), child:<Widget> ) |