Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to perform a hot reload in Flutter.
Flutter
void main() {
runApp(MyApp());
WidgetsBinding.instance.addPostFrameCallback((_) {
[1]();
});
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using hotRestart instead of hotReload causes a full restart.
Calling runApp again reloads the whole app, not just the UI.
✗ Incorrect
Calling runApp() again reloads the UI in Flutter, which is how hot reload is typically triggered programmatically.
2fill in blank
mediumComplete the code to perform a hot restart in Flutter.
Flutter
void main() {
runApp(MyApp());
[1]();
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using hotReload instead of hotRestart keeps the app state.
Calling setState only rebuilds widgets, not the whole app.
✗ Incorrect
The method hotRestart() restarts the Flutter app fully, clearing all state.
3fill in blank
hardFix the error in the code to trigger hot reload correctly.
Flutter
void main() {
runApp(MyApp());
WidgetsBinding.instance.[1](() {
print('Hot reload triggered');
});
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using addListener or addObserver causes errors as they don't exist here.
addReloadCallback is not a Flutter method.
✗ Incorrect
addPostFrameCallback schedules a callback after the current frame, suitable for hot reload triggers.
4fill in blank
hardFill both blanks to create a button that triggers hot reload when pressed.
Flutter
ElevatedButton(
onPressed: () {
[1]();
},
child: Text('[2]'),
) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using hotRestart() here restarts the whole app, not just UI.
Button text should match the action for clarity.
✗ Incorrect
The button calls hotReload() and shows text 'Reload UI' to indicate hot reload action.
5fill in blank
hardFill all three blanks to create a button that triggers hot restart and shows correct label.
Flutter
ElevatedButton(
onPressed: () {
[1]();
},
child: Text('[2]'),
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all<Color>([3]),
),
) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using hotReload() instead of hotRestart() changes behavior.
Incorrect color value causes UI errors.
✗ Incorrect
The button calls hotRestart(), shows 'Restart App' label, and has a red background color.