例如下面我统一定义一个空布局,方便全部使用
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class EmptyViewUtils {
static Widget emptyViewWidget({String text, VoidCallback onClick}) {
return Container(
alignment: Alignment.center,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
InkWell(
// ignore: unnecessary_statements
onTap: () {onClick();},
child: Image.network(
'https://resources.ninghao.org/images/candy-shop.jpg',
height: 150,
width: double.infinity,
),
),
SizedBox(
height: 20,
),
Text(text ?? '哎呦喂,列表暂时没数据呢')
],
),
);
}
}
使用方法当点击了 图片,会触发_controller.callRefresh();方法
emptyWidget: _count == 20 ? EmptyViewUtils.emptyViewWidget(onClick: () {_controller.callRefresh();
return;
}) : null,