Created
March 24, 2021 02:19
-
-
Save briansalvattore/3467ef702187fe97a086897020ed973f to your computer and use it in GitHub Desktop.
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 'package:flutter/material.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Flutter Demo', | |
debugShowCheckedModeBanner: false, | |
theme: ThemeData( | |
primarySwatch: Colors.blue, | |
), | |
home: MyHomePage(), | |
); | |
} | |
} | |
class MyHomePage extends StatefulWidget { | |
MyHomePage({Key key}) : super(key: key); | |
@override | |
_MyHomePageState createState() => _MyHomePageState(); | |
} | |
class _MyHomePageState extends State<MyHomePage> { | |
@override | |
void initState() { | |
super.initState(); | |
listenFuture((value) { | |
print('value $value'); | |
}); | |
} | |
void listenFuture(ValueSetter<String> callback) { | |
Future.delayed(Duration(seconds: 1), () { | |
callback('Brian'); | |
}); | |
Future.delayed(Duration(seconds: 2), () { | |
callback('Frank'); | |
}); | |
Future.delayed(Duration(seconds: 3), () { | |
callback('CervecereoDev'); | |
}); | |
Future.delayed(Duration(seconds: 4), () { | |
callback('Grinch Code'); | |
}); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text('Hello Grinch'), | |
), | |
body: Center( | |
child: Text( | |
'Holi', | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment