This file contains 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 printOrderMessage () async { | |
print('Awaiting user order...'); | |
var order = await fetchUserOrder(); | |
print('Your order is: $order'); | |
} | |
Future<String> fetchUserOrder() { | |
// Imagine that this function is more complex and slow. | |
return Future.delayed(Duration(seconds: 4), () => 'Large Latte'); | |
} |
This file contains 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 createOrderMessage () async { | |
var order = await getUserOrder(); | |
print('Awaiting user order...'); | |
print('Your order is: $order'); | |
} | |
Future<String> getUserOrder() { | |
return Future.delayed(Duration(seconds: 4), () => 'Large Latte'); | |
} |
This file contains 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 printOrderMessage () async { | |
try { | |
var order = await fetchUserOrder(); | |
print('Awaiting user order...'); | |
print(order); | |
} catch (err) { | |
print('Caught error: $err'); | |
} | |
} |
This file contains 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
// Implement changeUsername here |
This file contains 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
Future<void> fetchUserOrder() { | |
// Imagine that this function is fetching user info but encounters a bug | |
return Future.delayed(Duration(seconds: 3), () => throw Exception('Logout failed: user ID is invalid')); | |
} | |
void main() { | |
fetchUserOrder(); | |
print('Fetching user order...'); | |
} |
This file contains 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
// Synchronous | |
String createOrderMessage () { | |
var order = getUserOrder(); | |
return 'Your order is: $order'; | |
} | |
Future<String> getUserOrder() { | |
// Imagine that this function is more complex and slow | |
return Future.delayed(Duration(seconds: 4), () => 'Large Latte'); | |
} |
This file contains 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_web/material.dart'; | |
import 'package:flutter_web_test/flutter_web_test.dart'; | |
import 'package:flutter_web_ui/ui.dart' as ui; | |
class FetchedItem extends StatelessWidget { | |
Widget build(BuildContext context) { | |
return Container( | |
margin: EdgeInsets.only(top:20.0), | |
decoration: BoxDecoration(color: Colors.amber), | |
constraints: BoxConstraints.expand(height: 60) |
This file contains 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
// Copyright 2019 the Dart project authors. All rights reserved. | |
// Use of this source code is governed by a BSD-style license | |
// that can be found in the LICENSE file. | |
import 'dart:math'; | |
import 'package:flutter_web/material.dart'; | |
import 'package:flutter_web_test/flutter_web_test.dart'; | |
import 'package:flutter_web_ui/ui.dart' as ui; |
This file contains 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_web/material.dart'; | |
import 'package:flutter_web_test/flutter_web_test.dart'; | |
import 'package:flutter_web_ui/ui.dart' as ui; | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
home: Center( |
This file contains 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_web/material.dart'; | |
import 'package:flutter_web_test/flutter_web_test.dart'; | |
import 'package:flutter_web_ui/ui.dart' as ui; | |
Map<String, AnimatedIconData> _icons = { | |
'add_event': AnimatedIcons.add_event, | |
'arrow_menu': AnimatedIcons.arrow_menu, | |
'close_menu': AnimatedIcons.close_menu, | |
'event_add': AnimatedIcons.event_add, | |
'home_menu': AnimatedIcons.home_menu, |