[toc]
框架的接入
为了有更好的用户体验,我们对页面框架进行如下优化。
页面框架
1、错误页和空白页的页面,需要自定义
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
| import 'package:flutter_effect/flutter_effect.dart';
class TSBasePage extends BJHBasePage {
}
class _TSBasePageState extends BJHBasePageState<TSBasePage> { @override PreferredSizeWidget appBar() { return AppBar( title: Text("导航栏标题"), ); } @override Widget appBarWidget(BuildContext context) { return EasyAppBar( title: '我是成功页面的标题', ); return CommonAppBar( title: AppBarTitleWidget(text: '我是成功页面的标题'), leading: AppBarBackWidget( onPressed: () { Navigator.pop(context); }, ), ); }
@override Widget buildSuccessWidget(BuildContext context) { return bodyWidgets; } @override Widget buildNodataWidget(BuildContext context) { return StateNodataWidget( image: AssetImage('assets/images/nodata.png') mainTitle: '我是【请求成功,但无数据】的界面', subTitle: '', ); } @override Widget buildErrorWidget(BuildContext context) { return StateErrorWidget( errorRetry: getData, ); } void getData() { ... Api.getGoodsInfoList({}).then((ResultData data) { if (data.isSuccess) { ...
if (bean == null) { updateWidgetType(WidgetType.SuccessNoData); } else { updateWidgetType(WidgetType.SuccessWithData); }
} else { } }).catchError(onError) { updateWidgetType(WidgetType.ErrorNetwork); }; } }
|
其他,如果你还想设置初始页面,目前初始视图默认是空白视图
1 2 3 4 5 6 7 8 9 10 11 12
| @override Widget buildInitWidget(BuildContext context) { return Container( color: Colors.green, height: 100, child: Text( '我是初始视图...', style: TextStyle(color: Colors.blue, fontSize: 24), textAlign: TextAlign.center, ), ); }
|
3、背景色、背景图片
设置背景图片
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| @override Widget backgroundWidget(BuildContext context) { return Container( color: Color(0xFFF0F0F0), );
}
|
End