weui_toast_demo.dart 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/cupertino.dart';
  3. import 'package:cool_ui/cool_ui.dart';
  4. class WeuiToastDemo extends StatefulWidget{
  5. @override
  6. State<StatefulWidget> createState() {
  7. // TODO: implement createState
  8. return WeuiToastDemoState();
  9. }
  10. }
  11. class WeuiToastDemoState extends State<WeuiToastDemo>{
  12. bool isPaintBackgroud = false;
  13. @override
  14. Widget build(BuildContext context) {
  15. // TODO: implement build
  16. return Scaffold(
  17. appBar: AppBar(
  18. title: Text("WeuiToast Demo"),
  19. ),
  20. body: ListView(
  21. padding: const EdgeInsets.symmetric(vertical: 24.0, horizontal: 72.0),
  22. children: <Widget>[
  23. RaisedButton(
  24. color: Colors.blue[400],
  25. child: Text("成功",style: TextStyle(color: Colors.white),),
  26. onPressed: ()=>showWeuiSuccessToast(context:context,message: Text("成功啦!")),
  27. ),
  28. RaisedButton(
  29. color: Colors.blue[400],
  30. child: Text("加载中",style: TextStyle(color: Colors.white),),
  31. onPressed: (){
  32. var hide = showWeuiLoadingToast(context:context, message:Text("加载中"));
  33. Future.delayed(Duration(seconds: 5),(){
  34. hide();
  35. });
  36. },
  37. ),
  38. ].map((Widget button) {
  39. return Container(
  40. padding: const EdgeInsets.symmetric(vertical: 8.0),
  41. child: button
  42. );
  43. })
  44. .toList(),
  45. )
  46. );
  47. }
  48. }