TextStyle Extension #269
smallTrogdor
started this conversation in
Ideas
Replies: 3 comments 7 replies
-
What do you think @rawi-coding, @mosberger and @Grodien ? |
Beta Was this translation helpful? Give feedback.
1 reply
-
Beta Was this translation helpful? Give feedback.
0 replies
-
Based on these results I suggest defining separate font families without weight values in flutter:
fonts:
- family: SBBWebUltraLight
fonts:
- asset: packages/design_system_flutter/fonts/SBBWeb-UltraLight.ttf
- family: SBBWebThin
fonts:
- asset: packages/design_system_flutter/fonts/SBBWeb-Thin.ttf
- family: SBBWebLight
fonts:
- asset: packages/design_system_flutter/fonts/SBBWeb-Light.ttf
- family: SBBWebRoman
fonts:
- asset: packages/design_system_flutter/fonts/SBBWeb-Roman.ttf
- family: SBBWebBold
fonts:
- asset: packages/design_system_flutter/fonts/SBBWeb-Bold.ttf
- family: SBBWebCondensedBold
fonts:
- asset: packages/design_system_flutter/fonts/SBBWeb-Condensed-Bold.ttf
- family: SBBWebCondensedHeavy
fonts:
- asset: packages/design_system_flutter/fonts/SBBWeb-Condensed-Heavy.ttf and adapting my initial suggestion as follows: const TextStyle sbbTextStyle = SBBTextStyles.mediumLight;
extension SBBTextStylesExtensions on TextStyle {
TextStyle get ultraLight => copyWith(fontFamily: 'SBBWebUltraLight');
TextStyle get thin => copyWith(fontFamily: 'SBBWebThin');
TextStyle get light => copyWith(fontFamily: 'SBBWebLight');
TextStyle get roman => copyWith(fontFamily: 'SBBWebRoman');
TextStyle get bold => copyWith(fontFamily: 'SBBWebBold');
TextStyle get condensedBold => copyWith(fontFamily: 'SBBWebCondensedBold');
TextStyle get condensedHeavy => copyWith(fontFamily: 'SBBWebCondensedHeavy');
TextStyle get xxLarge => copyWith(fontSize: SBBTextStyles.xxLargeFontSize, height: SBBTextStyles.xxLargeFontHeight);
TextStyle get xLarge => copyWith(fontSize: SBBTextStyles.xLargeFontSize, height: SBBTextStyles.xLargeFontHeight);
TextStyle get large => copyWith(fontSize: SBBTextStyles.largeFontSize, height: SBBTextStyles.largeFontHeight);
TextStyle get medium => copyWith(fontSize: SBBTextStyles.mediumFontSize, height: SBBTextStyles.mediumFontHeight);
TextStyle get small => copyWith(fontSize: SBBTextStyles.smallFontSize, height: SBBTextStyles.smallFontHeight);
TextStyle get xSmall => copyWith(fontSize: SBBTextStyles.xSmallFontSize, height: SBBTextStyles.xSmallFontHeight);
TextStyle get italic => copyWith(fontStyle: FontStyle.italic);
TextStyle get normal => copyWith(fontStyle: FontStyle.normal);
} With this the dev will still be able to use |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Define Extensions on TextStyle to add some syntactic sugaring for using TextStyles.
For usage like
sbbTextStyle.roman.large
.Idea came from @VanHoangTran.
Beta Was this translation helpful? Give feedback.
All reactions