Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to apply the headline1 style from the current theme to the Text widget.
Flutter
Text( 'Hello Flutter', style: Theme.of(context).textTheme.[1], )
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using bodyText1 or caption which are smaller text styles.
Forgetting to access textTheme from Theme.of(context).
✗ Incorrect
The headline1 style is used for large titles. Using Theme.of(context).textTheme.headline1 applies this style to the Text widget.
2fill in blank
mediumComplete the code to get the bodyText2 style from the current theme and apply it to the Text widget.
Flutter
Text( 'Welcome to Flutter', style: Theme.of(context).textTheme.[1], )
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using headline6 which is for smaller headings.
Using button or overline which are for special text styles.
✗ Incorrect
bodyText2 is the default style for regular body text in Flutter's textTheme.
3fill in blank
hardFix the error in the code to correctly apply the subtitle1 style from the theme to the Text widget.
Flutter
Text( 'Subtitle Text', style: Theme.of(context).textTheme.[1], )
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Adding parentheses after the style name causing a syntax error.
Using the wrong style name.
✗ Incorrect
textTheme styles are properties, not methods. Remove the parentheses to fix the error.
4fill in blank
hardFill both blanks to create a Text widget that uses the caption style and sets its color to red.
Flutter
Text( 'Caption Text', style: Theme.of(context).textTheme.[1]?.copyWith(color: Colors.[2]), )
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using headline1 instead of caption for small text.
Setting color to blue instead of red.
✗ Incorrect
caption is the style for small text. copyWith lets you change the color to red.
5fill in blank
hardFill all three blanks to create a Text widget that uses headline4 style, makes the font weight bold, and sets the font size to 30.
Flutter
Text( 'Big Bold Text', style: Theme.of(context).textTheme.[1]?.copyWith(fontWeight: FontWeight.[2], fontSize: [3]), )
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using normal fontWeight instead of bold.
Using a smaller font size or wrong style.
✗ Incorrect
headline4 is a large text style. copyWith lets you change fontWeight to bold and fontSize to 30.