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
| void future_forEach(List<String> urls) { | |
| Future.forEach(urls, (url) { | |
| print('url:$url'); | |
| http.get(url).then((response) { | |
| print('statusCode:${response.statusCode}'); | |
| }); | |
| }).catchError((error) { print('$error'); }); | |
| } | |
| // output |
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
| void future_constructor_delayed() { | |
| Future.delayed( | |
| Duration(seconds: 3), | |
| () => 'Future.delayed(3 secs) done') | |
| .then((value) { print('$value'); }) | |
| .whenComplete( | |
| () { print('Future.delayed(3 secs) completed'); }); | |
| Future.delayed( | |
| Duration(seconds: 10), |
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
| class _MyListTiles extends State<MyListTiles> { | |
| var _checkboxValue = false; | |
| var _radioValue = 0; | |
| var _switchValue = false; | |
| @override | |
| Widget build(BuildContext context) { | |
| return ListView( | |
| padding: EdgeInsets.zero, | |
| children: <Widget>[ |
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
| @override | |
| Widget build(BuildContext context) { | |
| return Scaffold( | |
| // ... | |
| endDrawer: Drawer( | |
| child: Center(child: Text('This is endDrawer')), | |
| ), | |
| ); | |
| } |
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
| ListTile( | |
| title: Text('one-line with leading widget'), | |
| leading: GestureDetector( | |
| onTap: () { | |
| showDialog( | |
| context: context, | |
| builder: (BuildContext context) { | |
| return _dialog('Tapped leading'); | |
| } | |
| ); |
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
| ListTile( | |
| title: Text('Item 1'), | |
| leading: FlutterLogo(), | |
| onTap: () { | |
| showDialog( | |
| context: context, | |
| builder: (BuildContext context) { | |
| return _dialog('Tapped Item 1'); | |
| } | |
| ); |
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
| class _MyHomePageState extends State<MyHomePage> { | |
| AlertDialog _dialog(String title) { | |
| return AlertDialog( | |
| title: Text(title), | |
| actions: <Widget>[ | |
| FlatButton( | |
| child: Text('back'), | |
| onPressed: () { | |
| Navigator.pop(context); | |
| }, |
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
| transitionBuilder: (Widget child, Animation<double> animation) { | |
| return FadeTransition(opacity: animation, child: child); | |
| } |
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
| class _ClickCounterState extends State<ClickCounter> { | |
| int _count = 0; | |
| var keys = [1, 2, 3]; | |
| var colors = [Colors.red, Colors.blue, Colors.green]; | |
| var borderRadius = [50.0, 30.0, 0.0]; | |
| Widget createBox(int key) => Container( | |
| decoration: BoxDecoration( | |
| color: colors[key], | |
| borderRadius: BorderRadius.circular(borderRadius[key]), |
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
| class _MyHomePageState extends State<MyHomePage> { | |
| @override | |
| Widget build(BuildContext context) { | |
| return Scaffold( | |
| appBar: AppBar( | |
| title: Text('BottomAppBar demo'), | |
| ), | |
| body: Center( | |
| child: Text('body'), | |
| ), |