提交 5a1d3dab authored 作者: 袁静春's avatar 袁静春

提交:修改列表缺省图;

上级 2e1aa342
...@@ -194,7 +194,7 @@ packages: ...@@ -194,7 +194,7 @@ packages:
path: ".." path: ".."
relative: true relative: true
source: path source: path
version: "1.0.6" version: "1.0.7"
flutter_cupertino_datetime_picker: flutter_cupertino_datetime_picker:
dependency: transitive dependency: transitive
description: description:
......
import 'dart:io'; import 'dart:io';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'state_layout.dart'; import 'state_layout.dart';
/// 封装下拉刷新与加载更多 /// 封装下拉刷新与加载更多
class MyListViewPublic extends StatefulWidget { class MyListViewPublic extends StatefulWidget {
const MyListViewPublic( const MyListViewPublic({Key? key,
{Key? key,
required this.itemBuilder, required this.itemBuilder,
required this.requestData, required this.requestData,
this.pageSize = 10, this.pageSize = 10,
...@@ -18,8 +15,9 @@ class MyListViewPublic extends StatefulWidget { ...@@ -18,8 +15,9 @@ class MyListViewPublic extends StatefulWidget {
this.onRefresh, this.onRefresh,
this.canLoadMore = true, this.canLoadMore = true,
this.firstRefresh = true, this.firstRefresh = true,
this.emptyText}) this.emptyText,
: super(key: key); this.img,
}) : super(key: key);
final bool canLoadMore; //是否允许上拉 final bool canLoadMore; //是否允许上拉
final ItemBuilder itemBuilder; final ItemBuilder itemBuilder;
...@@ -27,13 +25,16 @@ class MyListViewPublic extends StatefulWidget { ...@@ -27,13 +25,16 @@ class MyListViewPublic extends StatefulWidget {
final bool firstRefresh; final bool firstRefresh;
final String? emptyText; final String? emptyText;
//(page, pageSize,_requestSuccess,_requestError){} // 数据为空时,缺省图
final String? img;
// (page, pageSize,_requestSuccess,_requestError){}
final RequestDataCallback requestData; final RequestDataCallback requestData;
/// 一页的数量,默认为10 // 一页的数量,默认为10
final int pageSize; final int pageSize;
/// padding属性使用时注意会破坏原有的SafeArea,需要自行计算bottom大小 // padding属性使用时注意会破坏原有的SafeArea,需要自行计算bottom大小
final EdgeInsetsGeometry? padding; final EdgeInsetsGeometry? padding;
final double? itemExtent; final double? itemExtent;
final Function? onRefresh; final Function? onRefresh;
...@@ -116,6 +117,7 @@ class _MyListViewPublicState extends State<MyListViewPublic> { ...@@ -116,6 +117,7 @@ class _MyListViewPublicState extends State<MyListViewPublic> {
child: listItemCount == 0 child: listItemCount == 0
? StateLayout( ? StateLayout(
type: stateType, type: stateType,
img: widget.img,
hintText: widget.emptyText, hintText: widget.emptyText,
) )
: ScrollConfiguration( : ScrollConfiguration(
......
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_clx_base/utils/image_utils.dart';
class StateLayout extends StatefulWidget { class StateLayout extends StatefulWidget {
const StateLayout({Key? key, required this.type, this.hintText})
: super(key: key);
final StateType type; final StateType type;
final String? img;
final String? hintText; final String? hintText;
const StateLayout({
Key? key,
required this.type,
this.img,
this.hintText,
}) : super(key: key);
@override @override
State<StateLayout> createState() => _StateLayoutState(); State<StateLayout> createState() => _StateLayoutState();
} }
...@@ -35,13 +42,16 @@ class _StateLayoutState extends State<StateLayout> { ...@@ -35,13 +42,16 @@ class _StateLayoutState extends State<StateLayout> {
Widget _otherWidget() { Widget _otherWidget() {
switch (widget.type) { switch (widget.type) {
case StateType.network: case StateType.network:
return _buildNormalView('icon_no_wifi', '无网络连接'); // return _buildNormalView('icon_no_wifi', '无网络连接');
return _buildNormalView(widget.img ?? '', '无网络连接');
case StateType.loading: case StateType.loading:
return Container(); return Container();
case StateType.empty: case StateType.empty:
return _buildNormalView('icon_empty', widget.hintText ?? '暂无数据'); // return _buildNormalView('default_drawing_1', widget.hintText ?? '暂无数据');
return _buildNormalView(widget.img ?? '', widget.hintText ?? '暂无数据');
case StateType.error: case StateType.error:
return _buildNormalView('icon_list_failure', '请求失败,请重试'); // return _buildNormalView('icon_list_failure', '请求失败,请重试');
return _buildNormalView(widget.img ?? '', '请求失败,请重试');
case StateType.success: case StateType.success:
return Container(); return Container();
} }
...@@ -52,17 +62,17 @@ class _StateLayoutState extends State<StateLayout> { ...@@ -52,17 +62,17 @@ class _StateLayoutState extends State<StateLayout> {
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[ children: <Widget>[
// Opacity( Opacity(
// opacity: 1, opacity: 1,
// child: Container( child: Container(
// height: 120.0, height: 120.0,
// width: 120.0, width: 120.0,
// decoration: BoxDecoration( decoration: BoxDecoration(
// image: DecorationImage( image: DecorationImage(
// image: ImageUtils.getAssetImage(img), image: ImageUtils.getAssetImage(img),
// ), ),
// ), ),
// )), )),
const SizedBox( const SizedBox(
height: 16.0, height: 16.0,
), ),
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论