linear_progress_dialog.dart 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import 'package:flutter/material.dart';
  2. class LinearProgressDialog extends StatefulWidget {
  3. final String message;
  4. const LinearProgressDialog(this.message, {Key key}) : super(key: key);
  5. @override
  6. LinearProgressDialogState createState() => LinearProgressDialogState();
  7. }
  8. class LinearProgressDialogState extends State<LinearProgressDialog> {
  9. double _progress;
  10. @override
  11. void initState() {
  12. _progress = 0;
  13. super.initState();
  14. }
  15. void setProgress(double progress) {
  16. setState(() {
  17. _progress = progress;
  18. });
  19. }
  20. @override
  21. Widget build(BuildContext context) {
  22. return WillPopScope(
  23. onWillPop: () async => false,
  24. child: AlertDialog(
  25. title: Text(
  26. widget.message,
  27. style: TextStyle(
  28. fontSize: 16,
  29. ),
  30. textAlign: TextAlign.center,
  31. ),
  32. content: LinearProgressIndicator(
  33. value: _progress,
  34. valueColor:
  35. AlwaysStoppedAnimation<Color>(Theme.of(context).buttonColor),
  36. ),
  37. ),
  38. );
  39. }
  40. }