提交 628efd97 authored 作者: 袁静春's avatar 袁静春

提交:修改参数命名;

上级 65715bcf
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_clx_base/utils/image_utils.dart';
import 'package:flutter_clx_base/widget/image_widget.dart';
class StateLayout extends StatefulWidget {
final StateType type;
final String? img;
final String? emptyImg;
final String? hintText;
const StateLayout({
Key? key,
required this.type,
this.img,
this.emptyImg,
this.hintText,
}) : super(key: key);
......@@ -44,15 +43,15 @@ class _StateLayoutState extends State<StateLayout> {
switch (widget.type) {
case StateType.network:
// return _buildNormalView('icon_no_wifi', '无网络连接');
return _buildNormalView(widget.img ?? '', '无网络连接');
return _buildNormalView(widget.emptyImg ?? '', '无网络连接');
case StateType.loading:
return Container();
case StateType.empty:
// return _buildNormalView('default_drawing_1', widget.hintText ?? '暂无数据');
return _buildNormalView(widget.img ?? '', widget.hintText ?? '暂无数据');
return _buildNormalView(widget.emptyImg ?? '', widget.hintText ?? '暂无数据');
case StateType.error:
// return _buildNormalView('icon_list_failure', '请求失败,请重试');
return _buildNormalView(widget.img ?? '', '请求失败,请重试');
return _buildNormalView(widget.emptyImg ?? '', '请求失败,请重试');
case StateType.success:
return Container();
}
......@@ -66,7 +65,7 @@ class _StateLayoutState extends State<StateLayout> {
const SizedBox(height: 30.0),
Offstage(
offstage: img.isEmpty,
offstage: _getShowImg(img),
child: ImageWidget.loadAssetImage(
img,
width: 133.5*2,
......@@ -86,6 +85,13 @@ class _StateLayoutState extends State<StateLayout> {
],
);
}
bool _getShowImg(String img) {
if (img.isNotEmpty && widget.type == StateType.empty) {
return false;
}
return true;
}
}
enum StateType {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论