Skip to content

Instantly share code, notes, and snippets.

@shyjuzz
Created January 22, 2019 09:26
Show Gist options
  • Save shyjuzz/82792e8e584e782be7bd27fb12c56233 to your computer and use it in GitHub Desktop.
Save shyjuzz/82792e8e584e782be7bd27fb12c56233 to your computer and use it in GitHub Desktop.
import 'package:progress_hud/progress_hud.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Prog Hud Demo'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
ProgressHUD _progressHUD;
@override
void initState() {
_progressHUD = new ProgressHUD(
backgroundColor: Colors.black12,
color: Colors.white,
containerColor: Colors.blue,
borderRadius: 5.0,
loading: false,
text: 'Loading...',
);
super.initState();
}
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text('ProgressHUD Demo'),
),
body: new Stack(
children: <Widget>[
_progressHUD,
new Positioned(
child: RaisedButton(
color: Colors.blueAccent,
child: Text('Login'),
onPressed: () {
_progressHUD.state.show();
//execute your code here and dismiss
Future.delayed(const Duration(seconds: 2), () {
_progressHUD.state.dismiss();
});
},
),
bottom: 30.0,
right: 10.0)
],
));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment