weui_toast_demo.dart 1.6 KB
Newer Older
1 2 3 4
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:cool_ui/cool_ui.dart';

Kevin's avatar
Kevin committed
5
class WeuiToastDemo extends StatefulWidget {
6 7 8 9 10 11 12
  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return WeuiToastDemoState();
  }
}

Kevin's avatar
Kevin committed
13
class WeuiToastDemoState extends State<WeuiToastDemo> {
14 15 16 17 18 19 20 21 22 23 24 25
  bool isPaintBackgroud = false;

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
        appBar: AppBar(
          title: Text("WeuiToast Demo"),
        ),
        body: ListView(
          padding: const EdgeInsets.symmetric(vertical: 24.0, horizontal: 72.0),
          children: <Widget>[
Kevin's avatar
Kevin committed
26
            MaterialButton(
27
              color: Colors.blue[400],
Kevin's avatar
Kevin committed
28 29 30 31 32
              child: Text(
                "成功",
                style: TextStyle(color: Colors.white),
              ),
              onPressed: () => showWeuiSuccessToast(context: context),
33
            ),
Kevin's avatar
Kevin committed
34
            MaterialButton(
35
              color: Colors.blue[400],
Kevin's avatar
Kevin committed
36 37 38 39 40 41 42
              child: Text(
                "加载中",
                style: TextStyle(color: Colors.white),
              ),
              onPressed: () {
                var hide = showWeuiLoadingToast(context: context);
                Future.delayed(Duration(seconds: 5), () {
43 44 45 46 47 48 49
                  hide();
                });
              },
            ),
          ].map((Widget button) {
            return Container(
                padding: const EdgeInsets.symmetric(vertical: 8.0),
Kevin's avatar
Kevin committed
50 51 52
                child: button);
          }).toList(),
        ));
53
  }
Kevin's avatar
Kevin committed
54
}