jd_loading 0.1.5

  • Readme
  • Changelog
  • Example
  • Installing
  • 69

jd_loading #

京东系APP统一Loading

示例预览 #

如何使用? #

依赖library:

dependencies:
  jd_loading: ^0.1.5
  

在入口页面初始化:

class MyApp extends StatelessWidget {
  double percentage = 0.0;

  @override
  Widget build(BuildContext context) {
    Application.appContext = context;
    //初始化
    JDLoading.init(context);
    return Scaffold(
    );
  }
}

在任意页面调用,展示loading:

JDLoading.show();
  

如果需要initState展示,则需要等页面渲染完,再调用,比如监听页面帧是否渲染完毕等

WidgetsBinding.instance
       .addPostFrameCallback((_) => _showDialogFrame(context));
  

如果不显示,需要重新传入BuildContext,(测试遇见使用FlutterBoost时候,需要重新传入context)

JDLoading.loading(context);
  

更多使用,参见example.

[0.1.5] - fix bug. #

  • 🌈 🌈 🌈 🌈fix Bug 🌈 🌈 🌈 🌈.

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);
                  Future.delayed(Duration(seconds: 5)).then((onValue) {
                    if (JDLoading.isShowing()) JDLoading.hide();
                  });
                }),
            RaisedButton(
                child: Text(
                  'Test New BuildContext)',
                  style: TextStyle(color: Colors.white),
                ),
                color: Colors.deepOrangeAccent,
                onPressed: () {
                  Navigator.push(
                    context,
                    MaterialPageRoute(builder: (context) => MyTwoApp()),
                  );
                })
          ],
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  jd_loading: ^0.1.5

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:jd_loading/jd_loading.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
38
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
69
Learn more about scoring.

We analyzed this package on Jul 11, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.15
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

Because:

  • jd_loading that is a package requiring null.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.2
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test