Code:
import 'package:flutter/material.dart';
import 'package:progress_button/progress_button.dart';
class ProgressButton5 extends StatefulWidget {
@override
_ProgressButton5State createState() => _ProgressButton5State();
}
class _ProgressButton5State extends State<ProgressButton5> {
ButtonState progressButtonState = ButtonState.normal;
@override
Widget build(BuildContext context) {
return Scaffold(
body: Builder(
builder: (context) => Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Padding(
padding: EdgeInsets.all(
(ButtonState.normal == progressButtonState ? 18.0 : 0.0)),
child: ProgressButton(
child: Text(
"Login",
style: TextStyle(color: Colors.white),
),
onPressed: () => clickButton(context),
buttonState: progressButtonState,
backgroundColor: Colors.indigo,
progressColor: Colors.white,
),
),
],
),
),
),
);
}
void clickButton(context) {
// ignore: deprecated_member_use
Scaffold.of(context).showSnackBar(
new SnackBar(
content: Text('Progress Button widget'),
duration: new Duration(
milliseconds: 800,
),
),
);
setState(() {
progressButtonState = ButtonState.inProgress;
});
Future.delayed(
new Duration(
milliseconds: 2000,
),
() {
setState(
() {
progressButtonState = ButtonState.normal;
},
);
},
);
}
}
0 Comments