jd_loading 0.1.6 copy "jd_loading: ^0.1.6" to clipboard
jd_loading: ^0.1.6 copied to clipboard

全局Loading封装

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:jd_loading/jd_loading.dart';

import 'application.dart';
import 'new_page.dart';

void main() {
  final app = MaterialApp(
    home: MyApp(),
  );
  runApp(app);
}

class MyApp extends StatelessWidget {
  double percentage = 0.0;

  @override
  Widget build(BuildContext context) {
    Application.appContext = context;
    JDLoading.init(context);
    return Scaffold(
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            RaisedButton(
                child: Text(
                  'Show⭕️Loading',
                  style: TextStyle(color: Colors.white),
                ),
                color: Colors.deepOrangeAccent,
                onPressed: () {
                  JDLoading.loading(context, isDismissible: true).then((value) {
                    print('aaa show loading callback');
                  });
                  Future.delayed(Duration(seconds: 3)).then((onValue) {
                    if (JDLoading.isShowing())
                      JDLoading.hide().then((status) {
                        print('aaa hide loading callback');
                      });
                  });
                }),
            RaisedButton(
                child: Text(
                  'Test New BuildContext',
                  style: TextStyle(color: Colors.white),
                ),
                color: Colors.deepOrangeAccent,
                onPressed: () {
                  Navigator.push(
                    context,
                    MaterialPageRoute(builder: (context) => MyTwoApp()),
                  );
                }),
            RaisedButton(
                child: Text(
                  'Test hide',
                  style: TextStyle(color: Colors.white),
                ),
                color: Colors.deepOrangeAccent,
                onPressed: () {
                  showDialog(
                      context: context,
                      builder: (_) => new AlertDialog(
                            title: new Text("Material Dialog"),
                            content: new Text("Hey! I'm a Test!"),
                            actions: <Widget>[
                              FlatButton(
                                child: Text('Close me!'),
                                onPressed: () {
                                  Navigator.of(context).pop();
                                },
                              )
                            ],
                          ));
                })
          ],
        ),
      ),
    );
  }
}
0
likes
25
pub points
0%
popularity

Publisher

unverified uploader

全局Loading封装

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

flutter, lottie

More

Packages that depend on jd_loading