createErrorView static method

Widget createErrorView({
  1. double iconWidth = 144,
  2. double iconHeight = 115,
  3. String? errorText,
  4. VoidCallback? onTap,
})

创建错误视图,子类可override自定义

Implementation

static Widget createErrorView({
  double iconWidth = 144,
  double iconHeight = 115,

  String? errorText,
  VoidCallback? onTap,
}) {
  return Column(
    mainAxisAlignment: MainAxisAlignment.center,
    children: <Widget>[
      Image.asset(
        'packages/zw_basic/assets/images/status_default_nonetwork.png',
        width: iconWidth,
        height: iconHeight,
        fit: BoxFit.cover,
      ),
      Container(
        margin: const EdgeInsets.only(top: 24),
        child: Text(
          textAlign: TextAlign.center,
          errorText ?? "加载失败,试试刷新页面",
          style: const TextStyle(fontSize: 14, color: Color(0xff999999)),
        ),
      ),
      Container(
        margin: const EdgeInsets.only(top: 24),
        child: ElevatedButton(
          onPressed: () {
            onTap?.call();
          },
          style: ElevatedButton.styleFrom(
            backgroundColor: AppColors.primaryColor,
            elevation: 2,
            padding: const EdgeInsets.only(
              left: 16,
              top: 10,
              right: 16,
              bottom: 10,
            ),
            shape: const RoundedRectangleBorder(
              borderRadius: BorderRadius.all(Radius.circular(24)),
            ),
          ),
          child: Text(
            "重新加载",
            style: const TextStyle(fontSize: 14, color: Colors.white),
          ),
        ),
      ),
    ],
  );
}