Skip to content

Instantly share code, notes, and snippets.

@briansalvattore
Created March 24, 2021 02:19
Show Gist options
  • Save briansalvattore/3467ef702187fe97a086897020ed973f to your computer and use it in GitHub Desktop.
Save briansalvattore/3467ef702187fe97a086897020ed973f to your computer and use it in GitHub Desktop.
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