1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- 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;
- 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});
- @override
- Widget build(BuildContext context) {
- return Column(
- mainAxisSize: MainAxisSize.min,
- children: <Widget>[
- Padding(
- padding: const EdgeInsets.fromLTRB(0, 50, 0, 0),
- child: Image.asset("lib/assets/img/${this.assets}"),
- ),
- Padding(
- padding: const EdgeInsets.fromLTRB(0, 12, 0, 12),
- child: Text(
- this.msg,
- style: Theme.of(context).textTheme.bodyText2,
- ),
- ),
- if (callback != null)
- Padding(
- padding: const EdgeInsets.all(16.0),
- child: OutlineButton(
- child: Text(
- "$action",
- style: TextStyle(fontSize: 14.0),
- ),
- clipBehavior: Clip.hardEdge,
- shape: StadiumBorder(),
- textColor: Color(0xff666666),
- color: Color(0xff666666),
- highlightedBorderColor: Theme.of(context).accentColor,
- highlightColor: Theme.of(context).accentColor,
- onPressed: callback,
- ),
- ),
- if (this.marginBottom == true)
- SizedBox(
- height: 50,
- )
- ],
- );
- }
- }
|