Skip to content

Instantly share code, notes, and snippets.

@mehrdadf7
Last active March 28, 2022 08:07
Show Gist options
  • Save mehrdadf7/134bb5098b9d9fc16da30d118b1fd84d to your computer and use it in GitHub Desktop.
Save mehrdadf7/134bb5098b9d9fc16da30d118b1fd84d to your computer and use it in GitHub Desktop.
Text styles in the flutter
extension TextExtension on TextStyle {
TextStyle white([double opacity = 1.0]) => copyWith(
color: ColorName.white.withOpacity(opacity),
);
// ANOTHER TEXT COLORS ...
TextStyle customColor(Color color, [double opacity = 1.0]) => copyWith(
color: color.withOpacity(opacity),
);
}
class TextStyles {
TextStyles._();
static const double _lineSpacing = 1.65;
static const double _textSizeVerySmall = 12.0;
static const double _textSizeSmall = 14.0;
// ANOTHER TEXT SIZE ...
static const TextStyle defaultStyle = TextStyle(
height: _lineSpacing,
color: ColorName.black,
);
//VERY SMALL
static TextStyle verySmall = defaultStyle.copyWith(
fontSize: _textSizeVerySmall,
fontFamily: defaultRegularFontName,
);
static TextStyle verySmallBold = verySmall.copyWith(
fontFamily: defaultBoldFontName,
);
//SMALL
static TextStyle small = defaultStyle.copyWith(
fontSize: _textSizeSmall,
fontFamily: defaultRegularFontName,
);
static TextStyle smallBold = small.copyWith(
fontFamily: defaultBoldFontName,
);
// ANOTHER TEXT STYLES ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment