Created
June 14, 2020 22:50
-
-
Save Meghatronics/559a52b83b13ec7120bb38ea8195a8f0 to your computer and use it in GitHub Desktop.
Sample loader
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'dart:async'; | |
| import 'package:flutter/material.dart'; | |
| void main() => runApp(PeekUp()); | |
| class PeekUp extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| return MaterialApp( | |
| title: 'Peek Up by FTC', | |
| home: GeekLoader(), | |
| ); | |
| } | |
| } | |
| class GeekLoader extends StatefulWidget { | |
| @override | |
| _GeekLoaderState createState() => _GeekLoaderState(); | |
| } | |
| class _GeekLoaderState extends State<GeekLoader> { | |
| bool isLoading = false; | |
| void runFuture() async { | |
| setState(() { | |
| isLoading = true; | |
| }); | |
| Timer(Duration(seconds: 5), () { | |
| setState(() { | |
| isLoading = false; | |
| }); | |
| }); | |
| } | |
| @override | |
| Widget build(BuildContext context) { | |
| return Scaffold( | |
| backgroundColor: Colors.white, | |
| body: Container( | |
| constraints: BoxConstraints.expand(), | |
| child: Column( | |
| crossAxisAlignment: CrossAxisAlignment.center, | |
| mainAxisAlignment: MainAxisAlignment.center, | |
| children: <Widget>[ | |
| Placeholder(fallbackHeight: 50), | |
| if (isLoading) | |
| CircularProgressIndicator(), | |
| Placeholder(fallbackHeight: 50), | |
| FlatButton( | |
| onPressed: () { | |
| runFuture(); | |
| }, | |
| child: Text('run a future'), | |
| ) | |
| ], | |
| ), | |
| )); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment