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

提交:修改列表缺省图;

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