combineWith method
TextStyle
combineWith({
- bool? inherit,
- Color? color,
- Color? backgroundColor,
- double? fontSize,
- FontWeight? fontWeight,
- FontStyle? fontStyle,
- double? letterSpacing,
- double? wordSpacing,
- TextBaseline? textBaseline,
- double? height,
- TextLeadingDistribution? leadingDistribution,
- Locale? locale,
- Paint? foreground,
- Paint? background,
- List<
Shadow> ? shadows, - List<
FontFeature> ? fontFeatures, - List<
FontVariation> ? fontVariations, - TextDecoration? decoration,
- Color? decorationColor,
- TextDecorationStyle? decorationStyle,
- double? decorationThickness,
- String? debugLabel,
- String? fontFamily,
- List<
String> ? fontFamilyFallback, - String? package,
- TextOverflow? overflow,
返回此 TextStyle 的副本,其中 other 中的非空字段替换了此 TextStyle 中相应的空字段。
换句话说,other 用于填充此 TextStyle 中的未指定(空)字段。
!!!: _package 字段是私有的,无法获取 package, 所以会直接替换 package 字段。
Implementation
TextStyle combineWith({
bool? inherit,
Color? color,
Color? backgroundColor,
double? fontSize,
FontWeight? fontWeight,
FontStyle? fontStyle,
double? letterSpacing,
double? wordSpacing,
TextBaseline? textBaseline,
double? height,
TextLeadingDistribution? leadingDistribution,
Locale? locale,
Paint? foreground,
Paint? background,
List<Shadow>? shadows,
List<FontFeature>? fontFeatures,
List<FontVariation>? fontVariations,
TextDecoration? decoration,
Color? decorationColor,
TextDecorationStyle? decorationStyle,
double? decorationThickness,
String? debugLabel,
String? fontFamily,
List<String>? fontFamilyFallback,
String? package,
TextOverflow? overflow,
}) {
assert(color == null || foreground == null, _kColorForegroundWarning);
assert(backgroundColor == null || background == null, _kColorBackgroundWarning);
String? newDebugLabel;
assert(() {
if (this.debugLabel != null) {
newDebugLabel = debugLabel ?? '(${this.debugLabel}).combineWith';
}
return true;
}());
return copyWith(
color: this.color ?? color,
backgroundColor: this.backgroundColor ?? backgroundColor,
fontSize: this.fontSize ?? fontSize,
fontWeight: this.fontWeight ?? fontWeight,
fontStyle: this.fontStyle ?? fontStyle,
letterSpacing: this.letterSpacing ?? letterSpacing,
wordSpacing: this.wordSpacing ?? wordSpacing,
textBaseline: this.textBaseline ?? textBaseline,
height: this.height ?? height,
leadingDistribution: this.leadingDistribution ?? leadingDistribution,
locale: this.locale ?? locale,
foreground: this.foreground ?? foreground,
background: this.background ?? background,
shadows: this.shadows ?? shadows,
fontFeatures: this.fontFeatures ?? fontFeatures,
fontVariations: this.fontVariations ?? fontVariations,
decoration: this.decoration ?? decoration,
decorationColor: this.decorationColor ?? decorationColor,
decorationStyle: this.decorationStyle ?? decorationStyle,
decorationThickness: this.decorationThickness ?? decorationThickness,
debugLabel: newDebugLabel ?? debugLabel,
fontFamily: this.fontFamily ?? fontFamily,
fontFamilyFallback: this.fontFamilyFallback ?? fontFamilyFallback,
overflow: this.overflow ?? overflow,
package: package,
);
}