Given the following Flutter widget, what font family will the displayed text use?
Text('Hello Flutter', style: TextStyle(fontFamily: 'MyCustomFont'))
Custom fonts must be registered in the pubspec.yaml file before use.
If the font family is registered correctly in pubspec.yaml, Flutter uses it for the text style.
Choose the correct way to declare a custom font in pubspec.yaml.
Look for the correct indentation and keys under flutter.
The correct syntax uses 'fonts' under 'flutter', with 'family' and a list of 'fonts' assets.
Consider you added a new font file and updated pubspec.yaml but did not run 'flutter pub get'. What will happen when you run the app?
Think about how Flutter updates dependencies and assets.
Without running 'flutter pub get', the new font asset is not registered, so Flutter falls back to the default font.
Given this pubspec.yaml snippet and Flutter code, why does the custom font not appear?
flutter:
fonts:
- family: MyFont
fonts:
- asset: fonts/MyFont-Regular.ttf
Text('Sample', style: TextStyle(fontFamily: 'MyCustomFont'))Check the font family names carefully.
The TextStyle uses 'MyCustomFont' but the pubspec.yaml declares 'MyFont'. They must match exactly.
You have multiple font files for different weights (e.g., Regular, Bold) under the same family. How should you declare them in pubspec.yaml to enable Flutter to use them automatically?
Look for how pubspec.yaml supports font weight declarations.
Flutter uses the 'weight' property to map font files to font weights under the same family.