flutter-Decoration

Decoration

继承

Object-> Diagnosticable-> Decoration

实现

BoxDecoration
FlutterLogoDecoration
ShapeDecoration
UnderlineTabIndicator

在这里插入图片描述

注解

@Immutable 啥玩意? 英文翻译不可变,创建了就不可变了,变了就会生成一个新的 这个不是重点,继续下面翻译

构造方法(加了一个const??)

Abstract const constructor. This constructor enables subclasses to provide const constructors so that they can be used in const expressions.
抽象const构造函数。此构造函数使子类能够提供const构造函数,以便它们可以在const表达式中使用

const Decoration()

BoxDecoration

Object-> Diagnosticable-> Decoration->BoxDecoration

构造方法

const BoxDecoration({
  this.color,
  this.image,
  this.border,
  this.borderRadius,
  this.boxShadow,
  this.gradient,
  this.backgroundBlendMode,
  this.shape = BoxShape.rectangle,
}) : assert(shape != null),
     assert(
       backgroundBlendMode == null || color != null || gradient != null,
       'backgroundBlendMode applies to BoxDecoration\'s background color or '
       'gradient, but no color or gradient was provided.'
     );

创建一个盒子装饰。
  • 如果color为null,则此装饰不会绘制背景颜色
  • 如果color为null,则此装饰不会绘制背景颜色。
  • 如果image为null,则此装饰不会绘制背景图像。
  • 如果border为null,则此装饰不会绘制边框。
  • 如果borderRadius为null,则此装饰使用更高效的背景绘制命令。该borderRadius如果参数必须为空shape是 BoxShape.circle。
  • 如果boxShadow为null,则此装饰不会绘制阴影。
  • 如果gradient为null,则此装饰不会绘制渐变。
  • 如果backgroundBlendMode为null,则此装饰使用BlendMode.srcOver进行绘制
该shape参数不能为空。 final修饰必须要在构造方法赋值
属性
backgroundBlendMode → BlendMode
border → BoxBorder 边框
borderRadius → BorderRadiusGeometry 圆角
boxShadow → List 一个BoxShadow集合
color → Color 背景色
gradient → Gradient RadialGradient
image → DecorationImage 背景图片
padding → EdgeInsetsGeometry
shape → BoxShape 形状,默认矩形
shape → ShapeBorder 形状,ShapeDecoration的属性和BoxDecoration的区别

UnderlineTabIndicator

与TabBar.indicator一起使用以在选定选项卡下方绘制水平线。

属性
borderSide → BorderSide 盒子边框的一面
insets → EdgeInsetsGeometry ??

下面需要学习的widget

发布了96 篇原创文章 · 获赞 12 · 访问量 15万+

猜你喜欢

转载自blog.csdn.net/yujunlong3919/article/details/98486129
今日推荐