flutter_overlay_loader 0.0.2 flutter_overlay_loader: ^0.0.2 copied to clipboard
A new Flutter package for developer who want to show overlay loader or progressbar for completing future task.
import 'package:flutter/material.dart';
import 'package:flutter_overlay_loader/flutter_overlay_loader.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Overlay Loader',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Overlay Loader example'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateMixin {
@override
void dispose() {
Loader.hide();
print("Called dispose");
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'Loading...',
),
RaisedButton(
child: Text("ShowLoader 1"),
onPressed: (){
//default
Loader.show(context,progressIndicator:LinearProgressIndicator());
Future.delayed(Duration(seconds: 10),(){
Loader.hide();
});
}),
RaisedButton(
child: Text("ShowLoader 2"),
onPressed: (){
Loader.show(context,progressIndicator: CircularProgressIndicator(backgroundColor: Colors.red,),themeData: Theme.of(context).copyWith(accentColor: Colors.green));
Future.delayed(Duration(seconds: 3),(){
Loader.hide();
});
}),
RaisedButton(
child: Text("ShowLoader 3"),
onPressed: (){
Loader.show(
context,progressIndicator: CircularProgressIndicator(),
themeData: Theme.of(context).copyWith(accentColor: Colors.black38),
overlayColor:Color(0x99E8EAF6)
);
Future.delayed(Duration(seconds: 3),(){
Loader.hide();
});
}),
],
),
),
);
}
}