https://pub.dev/packages/headup_loading
A Flutter plugin for heads up display progress indicator
- Depend on it
Add this to your package's pubspec.yaml file:
dependencies:
headup_loading: ^any
- Install it
You can install packages from the command line:
with Flutter:
$ flutter packages get
Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more. 3. Import it
Now in your Dart code, you can use:
import 'package:headup_loading/headup_loading.dart';
EXAMPLE:
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:headup_loading/headup_loading.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(home: Home());
}
}
class Home extends StatefulWidget {
@override
_HomeState createState() => new _HomeState();
}
class _HomeState extends State<Home> {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: new AppBar(
title: new Text('HeadUp Loading Demo'),
),
body: ListView(
shrinkWrap: true,
children: <Widget>[
RaisedButton(
onPressed: showLoading, child: new Text("Show Loading")),
RaisedButton(
onPressed: showLoadingCupertino, child: new Text("Show Loading Cupertino"))
],
)),
);
}
Future<void> showLoading() async {
HeadUpLoading.show(context);
Future.delayed(Duration(seconds: 2)).then((val) {
HeadUpLoading.hide();
});
}
Future<void> showLoadingCupertino() async {
CupertinoHeadUpLoading.show(context);
Future.delayed(Duration(seconds: 2)).then((val) {
CupertinoHeadUpLoading.hide();
});
}
}
If you like my content, please consider buying me a coffee. Thank you for your support!
bagi yang dari Indonesia bisa lewat saweria berikut