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

class EmptyPage extends StatefulWidget {
  final String content;
  final String imgname;
  final Color bgcolor;

  const EmptyPage(
      {Key key,
      this.content,
      this.imgname = "bg_error",
      this.bgcolor = MyColours.color_ffffff})
      : super(key: key);

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

class EmptyPageState extends State<EmptyPage> {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Container(
        width: double.infinity,
        height: double.infinity,
        color: widget.bgcolor,
        child: Stack(
          children: <Widget>[
            Container(
              width: double.infinity,
              height: double.infinity,
              margin: EdgeInsets.only(top: ScreenUtil().setWidth(132)),
              child: Column(
                mainAxisSize: MainAxisSize.min,
                children: <Widget>[
                  Image.asset(
                    Utils.getImgPath(widget.imgname),
                    width: ScreenUtil().setWidth(520),
                    height: ScreenUtil().setWidth(384),
                  ),
                  VEmptyView(40),
                  Text(
                    widget.content ?? "数据为空",
                    textAlign: TextAlign.center,
                    strutStyle: StrutStyle(leading: ScreenUtil().setWidth(1)),
                    style: TextStyle(
                        fontSize: ScreenUtil().setSp(28),
                        color: MyColours.color_353535),
                  )
                ],
              ),
            ),
          ],
        ));
  }
}