flutter-border

简介: flutter-border

Border

继承

Object-> ShapeBorder-> BoxBorder-> Border

构造方法

很简单的构造方法,用四个BorderSide组成,

  const Border({
    this.top =BorderSide.none,
    this.right = BorderSide.none,
    this.bottom = BorderSide.none,
    this.left = BorderSide.none,
  }) : assert(top != null),
       assert(right != null),
       assert(bottom != null),
       assert(left != null);
       
factory Border.all({
    Color color = const Color(0xFF000000),
    double width = 1.0,
    BorderStyle style = BorderStyle.solid,
  }) {
    final BorderSide side = BorderSide(color: color, width: width, style: style);
    return Border.fromBorderSide(side);
  }
  
 const Border.fromBorderSide(BorderSide side)
      : assert(side != null),
        top = side,
        right = side,
        bottom = side,
        left = side;
       
BorderStyle和BorderSide
BorderStyle

枚举类,none(跳过不绘制) solid实线 虚线在哪里?

盒子边框的一面

一个边界是由四个BorderSide对象:Border.top, Border.left,Border.right和Border.bottom。请注意,将BorderSide.width设置为0.0将导致细线渲染。BorderSide.width中提供了更复杂的解释。


BorderSide
构造方法
 const BorderSide({
    this.color = const Color(0xFF000000),
    this.width = 1.0,
    this.style = BorderStyle.solid,
  }) : assert(color != null),
       assert(width != null),
       assert(width >= 0.0),
       assert(style != null);


属性
color → Color 边框颜色
style → BorderStyle 边框样式
width → double 边框宽度


BoxShadow

由盒子投下的阴影。

Object-> Shadow-> BoxShadow

构造方法
  const BoxShadow({
    Color color = const Color(0xFF000000),
    Offset offset = Offset.zero,
    double blurRadius = 0.0,
    this.spreadRadius = 0.0,
  }) : super(color: color, offset: offset, blurRadius: blurRadius);


属性
spreadRadius → double 扩展程度
blurRadius → double 模糊程度
blurSigma → double convertRadiusToSigma(blurRadius)
color → Color 阴影颜色
offset → Offset 偏移
BoxShape

渲染Border或BoxDecoration时使用的形状

如果需要对形状进行插值或动画处理,请考虑直接使用ShapeBorder子类(使用ShapeDecoration),而不是使用BoxShape和Border。该边框类不能在不同形状之间的插值。

Code
enum BoxShape {
//RoundedRectangleBorder,ShapeBorder
rectangle,
//CircleBorderm,ShapeBorder
circle,
}
BorderRadius

矩形每个角的一组不可变半径

通过使用BoxDecoration时形状是BoxShape.rectangle。

BorderRadius类根据视角指定偏移,例如 topLeft。这些值不受TextDirection的影响。要支持从左到右和从右到左布局,请考虑使用 BorderRadiusDirectional,它以相对于TextDirection(通常从环境方向性获得)的术语表示。


继承

Object->BorderRadiusGeometry->BorderRadius

Code
 const BorderRadius.all(Radius radius) : this.only(
    topLeft: radius,
    topRight: radius,
    bottomLeft: radius,
    bottomRight: radius,
  );


Radius(半径)

圆形或者椭圆

const Radius.circular(double radius) : this.elliptical(radius, radius); 圆形

const Radius.elliptical(this.x, this.y); 椭圆

相关文章
Flutter Getx 路由 until 方法帮助你跳转指定路由
不少同学都会问我,这样一个场景,当我点击商品列表,进入商品页,点击购买,支付成功后,想返回商品页,或者我的中心的订单列表。怎么做,这中间跨度了 n 个路由。 我不只一次的推荐 GetX 的 until 方法,和 offNamedUntil 方法。 我写了个 demo 今天我们就一起来看下这两个方法如何使用。
2271 0
Flutter Getx 路由 until 方法帮助你跳转指定路由
|
安全 数据安全/隐私保护 iOS开发
flutter 代码混淆
flutter 代码混淆
461 0
|
Android开发
ANR怎么产生的,怎么分析ANR?(二)
ANR怎么产生的,怎么分析ANR?(二)
257 0
|
10月前
|
索引
【Flutter 开发必备】AzListView 组件全解析,打造丝滑索引列表!
在 Flutter 开发中,AzListView 是实现字母索引分类列表的理想选择。它支持 A-Z 快速跳转、悬浮分组标题、自定义 UI 和高效性能,适用于通讯录、城市选择等场景。本文将详细解析 AzListView 的核心参数和实战示例,助你轻松实现流畅的索引列表。
487 7
|
前端开发 API Android开发
Flutter最强大的图表库fl_chart的使用
Flutter最强大的图表库fl_chart的使用
1647 1
|
安全 Android开发 对象存储
使用 obfuscation 代码混淆保护你的 Flutter 应用程序
本文将会和大家说下保护代码的重要性,和如何给程序加上混淆编译功能。 尽可能的不要在你的程序中写死各种服务秘钥,比如 oss 容易被盗用。
468 1
使用 obfuscation 代码混淆保护你的 Flutter 应用程序
|
算法 Android开发 开发者
Jetpack-Compose 学习笔记(三)—— Compose 的自定义“View”(上)
Jetpack-Compose 学习笔记(三)—— Compose 的自定义“View”(上)
423 0
flutter中使用图标(含自制图标库方案)
flutter中使用图标(含自制图标库方案)
3698 0
|
弹性计算 算法 测试技术
芯片研发设计单月算力成本降了50%怎么做到的?
面对芯片设计中日益严峻的算力挑战,S半导体经历了从自建HPC集群到结合公有云的尝试,导致成本上升。后来,采用MMCloud解决方案,首月即实现50%的算力成本降低。MMCloud通过大规模集群管理、算力碎片整理和机型动态调整实现精细化调度,帮助S半导体提升了研发效率并降低成本,展示了在行业寒冬中的降本增效策略。
350 5
|
存储 XML 编译器
【Android 从入门到出门】第二章:使用声明式UI创建屏幕并探索组合原则
【Android 从入门到出门】第二章:使用声明式UI创建屏幕并探索组合原则
429 3

热门文章

最新文章