page_error.dart 2.29 KB

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/widgets/v_empty_view.dart';

class ErrorPage extends StatefulWidget {
  final String content;

  final String btnTitle;

  final VoidCallback? callback;

  const ErrorPage(
      {Key? key,
      this.callback,
      this.content = "哎呀~网络好像走失了呢",
      this.btnTitle = '点击刷新'})
      : super(key: key);

  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return new ErrorPageState();
  }
}

class ErrorPageState extends State<ErrorPage> {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Container(
        width: double.infinity,
        height: double.infinity,
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: <Widget>[
            VEmptyView(120),
            Image.asset(
              "assets/bg_error.png",
              width: ScreenUtil().setWidth(520),
              height: ScreenUtil().setWidth(384),
            ),
            VEmptyView(40),
            Text(
              "${widget.content}",
              style: TextStyle(
                  fontSize: ScreenUtil().setSp(28),
                  color: MyColours.color_353535),
            ),
            VEmptyView(20),
            widget.callback != null
                ? GestureDetector(
                    onTap: widget.callback,
                    child: Container(
                      width: ScreenUtil().setWidth(152),
                      height: ScreenUtil().setWidth(58),
                      decoration: BoxDecoration(
                          color: MyColours.app_main,
                          borderRadius: BorderRadius.all(
                              Radius.circular(ScreenUtil().setWidth(28)))),
                      child: Center(
                        child: Text(
                          widget.btnTitle,
                          style: TextStyle(
                              fontSize: ScreenUtil().setSp(28),
                              color: MyColours.color_ffffff),
                        ),
                      ),
                    ),
                  )
                : Container()
          ],
        ));
  }
}