12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/material.dart';
- class RequestErrorWidget extends StatelessWidget {
- final VoidCallback? callback;
- final String msg;
- final String assets;
- final String action;
- final bool marginBottom;
- final double padding;
- static const String ASSETS_NO_NETWORK = "emptypage-image-nonetwork.png";
- static const String ASSETS_NO_COMMENT = "emptypage-image-nocomment.png";
- static const String ASSETS_NO_INVITATION = "emptypage-image-noinvitation.png";
- static const String ASSETS_NO_MOTION = "emptypage-image-nomotion.png";
- static const String ASSETS_NO_RANK = "emptypage-image-noattainment.png";
- RequestErrorWidget(this.callback,
- {this.msg = "网络出错啦,请点击按钮重新加载",
- this.assets = ASSETS_NO_NETWORK,
- this.action = "重新加载",
- this.marginBottom = true,
- this.padding = 50});
- @override
- Widget build(BuildContext context) {
- return Column(
- mainAxisSize: MainAxisSize.min,
- children: <Widget>[
- Padding(
- padding: EdgeInsets.fromLTRB(0, this.padding, 0, 0),
- child: Image.asset("lib/assets/img/${this.assets}"),
- ),
- Padding(
- padding: const EdgeInsets.all(12.0),
- child: Text(
- this.msg,
- style: Theme.of(context).textTheme.bodyText2!,
- ),
- ),
- if (callback != null)
- Padding(
- padding: const EdgeInsets.all(16.0),
- child: OutlinedButton(
- child: Text(
- "$action",
- style: Theme.of(context).textTheme.bodyText1,
- ),
- style: ButtonStyle(shape: MaterialStateProperty.all(StadiumBorder())),
- clipBehavior: Clip.hardEdge,
- onPressed: callback,
- ),
- ),
- if (this.marginBottom == true)
- SizedBox(
- height: this.padding,
- )
- ],
- );
- }
- }
|