beauty_loading 0.0.2 beauty_loading: ^0.0.2 copied to clipboard
A beautiful Flutter loading package.
import 'package:flutter/material.dart';
import 'package:beauty_loading/beauty_loading.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
void initState() {
super.initState();
/// 显示loading
BeautyLoading.show(context);
/// 3秒后关闭loading
Future.delayed(const Duration(milliseconds: 3000), () {
BeautyLoading.dismiss();
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Container()
);
}
}