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; 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 = "重新加载"}); @override Widget build(BuildContext context) { return Column( mainAxisSize: MainAxisSize.min, children: [ 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, ), ), SizedBox( height: 100, ) ], ); } }