提交 5416d3b5 authored 作者: shixiaochen's avatar shixiaochen

1、修复BaseListWidget展示多个loading问题

上级 b85f0a03
...@@ -36,4 +36,6 @@ ...@@ -36,4 +36,6 @@
* 网络请求兼容code整形、字符串判断 * 网络请求兼容code整形、字符串判断
* ## 1.1.8 * ## 1.1.8
* 网络请求兼容data返回null * 网络请求兼容data返回null
* ## 1.1.9
* 修复BaseListWidget展示多个loading问题
\ No newline at end of file
...@@ -236,6 +236,7 @@ class _BaseListWidgetState extends State<BaseListWidget> { ...@@ -236,6 +236,7 @@ class _BaseListWidgetState extends State<BaseListWidget> {
emptyImg: "default_drawing_1", emptyImg: "default_drawing_1",
errorImg: "default_drawing_5", errorImg: "default_drawing_5",
onRefresh: _controller.reload, onRefresh: _controller.reload,
loadingWidget: const SizedBox(),
); );
}, },
childCount: 1, childCount: 1,
......
...@@ -6,8 +6,9 @@ class StateLayout extends StatefulWidget { ...@@ -6,8 +6,9 @@ class StateLayout extends StatefulWidget {
final StateType type; final StateType type;
final String? emptyImg; final String? emptyImg;
final String? hintText; final String? hintText;
final String? errorImg; //加载错误,图片 final String? errorImg; //加载错误,图片
final Function? onRefresh; final Function? onRefresh;
final Widget? loadingWidget;
const StateLayout({ const StateLayout({
Key? key, Key? key,
...@@ -16,6 +17,7 @@ class StateLayout extends StatefulWidget { ...@@ -16,6 +17,7 @@ class StateLayout extends StatefulWidget {
this.hintText, this.hintText,
this.errorImg, this.errorImg,
this.onRefresh, this.onRefresh,
this.loadingWidget,
}) : super(key: key); }) : super(key: key);
@override @override
...@@ -23,13 +25,13 @@ class StateLayout extends StatefulWidget { ...@@ -23,13 +25,13 @@ class StateLayout extends StatefulWidget {
} }
class _StateLayoutState extends State<StateLayout> { class _StateLayoutState extends State<StateLayout> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SizedBox( return SizedBox(
width: double.infinity, width: double.infinity,
child: child: widget.type == StateType.loading
widget.type == StateType.loading ? _loadingWidget() : _otherWidget(), ? widget.loadingWidget ?? _loadingWidget()
: _otherWidget(),
); );
} }
...@@ -70,11 +72,13 @@ class _StateLayoutState extends State<StateLayout> { ...@@ -70,11 +72,13 @@ class _StateLayoutState extends State<StateLayout> {
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[ children: <Widget>[
const SizedBox(height: 30.0), const SizedBox(height: 30.0),
img != null && img.isNotEmpty ?ImageWidget.loadAssetImage( img != null && img.isNotEmpty
img, ? ImageWidget.loadAssetImage(
width: 133.5*2, img,
height: 95*2, width: 133.5 * 2,
): const SizedBox(), height: 95 * 2,
)
: const SizedBox(),
Text( Text(
hintText, hintText,
style: const TextStyle( style: const TextStyle(
...@@ -88,7 +92,6 @@ class _StateLayoutState extends State<StateLayout> { ...@@ -88,7 +92,6 @@ class _StateLayoutState extends State<StateLayout> {
), ),
); );
} }
} }
enum StateType { enum StateType {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论