createBorderSide static method
TxBorderSide
createBorderSide(
- BuildContext? context, {
- Color? color,
- double? width,
- List<
double> ? dashPattern, - LinearGradient? gradient,
override
计算表示分隔线的 TxBorderSide。
如果 color 为空,则使用 DividerThemeData.color。 如果它也为 null,则使用
ThemeData.dividerColor。
如果 width 为 null,则使用 DividerThemeData.thickness。 如果它也为 null,
则默认为 0.0(细线边框)。
/// 如果context 为null,则使用BorderSide 的默认颜色,并使用0.0 的默认宽度。
Implementation
static TxBorderSide createBorderSide(
BuildContext? context, {
Color? color,
double? width,
List<double>? dashPattern,
LinearGradient? gradient,
}) {
Color? effectiveColor;
if (gradient == null) {
effectiveColor = color ??
(context != null
? (DividerTheme.of(context).color ??
Theme.of(context).dividerColor)
: null);
}
final double effectiveWidth = width ??
(context != null ? DividerTheme.of(context).thickness : null) ??
0.0;
// 防止断言,因为上下文可能为空且未指定颜色。
if (effectiveColor == null) {
return TxBorderSide(
gradient: gradient,
dashPattern: dashPattern,
width: effectiveWidth,
);
}
return TxBorderSide(
color: effectiveColor,
width: effectiveWidth,
gradient: gradient,
dashPattern: dashPattern,
);
}