Skip to content

Instantly share code, notes, and snippets.

@Schnodderbalken
Created June 11, 2020 12:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Schnodderbalken/149ff37c8ad978a8311711b47445e59d to your computer and use it in GitHub Desktop.
Save Schnodderbalken/149ff37c8ad978a8311711b47445e59d to your computer and use it in GitHub Desktop.
Flutter loading indicator widget with text
import 'package:flutter/material.dart';
class LoadingIndicator extends StatelessWidget{
LoadingIndicator({this.text = ''});
final String text;
@override
Widget build(BuildContext context) {
var displayedText = text;
return Container(
padding: EdgeInsets.all(16),
color: Colors.black87,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
_getLoadingIndicator(),
_getHeading(context),
_getText(displayedText)
]
)
);
}
Padding _getLoadingIndicator() {
return Padding(
child: Container(
child: CircularProgressIndicator(
strokeWidth: 3
),
width: 32,
height: 32
),
padding: EdgeInsets.only(bottom: 16)
);
}
Widget _getHeading(context) {
return
Padding(
child: Text(
'Please wait …',
style: TextStyle(
color: Colors.white,
fontSize: 16
),
textAlign: TextAlign.center,
),
padding: EdgeInsets.only(bottom: 4)
);
}
Text _getText(String displayedText) {
return Text(
displayedText,
style: TextStyle(
color: Colors.white,
fontSize: 14
),
textAlign: TextAlign.center,
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment