当前位置:网站首页>Flutter Clip剪裁组件
Flutter Clip剪裁组件
2022-06-23 13:14:00 【xiangxiongfly915】
Flutter Clip剪裁组件
简述
Flutter提供了一些剪裁工具,用于对组件的剪裁。
使用
原图

Image.asset("images/avatar.jpg", width: 100, height: 100);
ClipRect
矩形剪裁。

ClipRect(
child: Align(
child: avatar,
alignment: Alignment.topCenter,
heightFactor: 0.5,
),
)
ClipOval
圆形剪裁。

ClipOval(
child: avatar,
clipBehavior: Clip.antiAlias, //抗锯齿,通常用于处理圆形和弧形
)
ClipRRect
矩形圆角剪裁。

ClipRRect(
child: avatar,
borderRadius: BorderRadius.circular(10),
)
ClipPath
路径剪裁。
shape:ShapeBorder类型,定义剪裁形状。
- RoundedRectangleBorder:圆角矩形。
- ContinuousRectangleBorder:直线与圆角平滑过渡,与RoundedRectangleBorder类似,但圆角效果小一些。
- StadiumBorder:类似足球场,两端半圆。
- BeveledRectangleBorder:斜角矩形。

ClipPath.shape(
shape: const StadiumBorder(),
child: SizedBox(
width: 100,
height: 60,
child: Image.asset("images/avatar.jpg", fit: BoxFit.cover),
),
),
自定义剪裁

Container(
color: Colors.red,
child: ClipRect(
clipper: MyClipper1(),
child: avatar,
),
)
class MyClipper1 extends CustomClipper<Rect> {
@override
Rect getClip(Size size) {
return const Rect.fromLTWH(0, 0, 30, 30);
}
@override
bool shouldReclip(covariant CustomClipper<Rect> oldClipper) {
return false;
}
}

Container(
color: Colors.green,
child: ClipPath(
clipper: TrianglePath(),
child: avatar,
),
)
class TrianglePath extends CustomClipper<Path> {
@override
Path getClip(Size size) {
var path = Path();
path.moveTo(size.width / 2, 0);
path.lineTo(0, size.height);
path.lineTo(size.width, size.height);
path.close();
return path;
}
@override
bool shouldReclip(covariant CustomClipper<Path> oldClipper) {
return true;
}
}
边栏推荐
- 2022软科大学专业排名出炉!西电AI专业排名超清北,南大蝉联全国第一 !
- 20000 words + 30 pictures | MySQL log: what is the use of undo log, redo log and binlog?
- [Yunzhou said live room] - digital security special session will be officially launched tomorrow afternoon
- Face registration, unlock, respond, catch all
- Common usage of OS (picture example)
- 通过 OpenVINO Model Server和 TensorFlow Serving简化部署
- IEEE transaction journal revision process record
- Js: get the maximum zindex (Z-index) value of the page
- Online text entity extraction capability helps applications analyze massive text data
- How do I turn on / off the timestamp when debugging the chrome console?
猜你喜欢
![[Yunzhou said live room] - digital security special session will be officially launched tomorrow afternoon](/img/56/a6a9fbba0a9fc212883b469bb857c5.png)
[Yunzhou said live room] - digital security special session will be officially launched tomorrow afternoon

What is the principle of live CDN in the process of building the source code of live streaming apps with goods?

怎么手写vite插件

windows 安装 MySQL

MySQL single database and table splitting using MYCAT

微信小程序之获取php后台数据库转化的json

Multi-Camera Detection of Social Distancing Reference Implementation

Develop a powerful tool for increasing efficiency - vscode plug-in sharing in 2022

Shell process control - 39. Special process control statements

Quarkus+saas multi tenant dynamic data source switching is simple and perfect
随机推荐
What does it mean for AI developers after 2022
栈和队列的基本使用
前AMD芯片架构师吐槽,取消 K12 处理器项目是因为 AMD 怂了!
Intel ® extensions for pytorch* accelerate pytorch
『忘了再学』Shell流程控制 — 39、特殊流程控制语句
How do I turn on / off the timestamp when debugging the chrome console?
Detailed description of Modelsim installation steps
人脸注册,解锁,响应,一网打尽
OS的常见用法(图片示例)
Filtre de texte en ligne inférieur à l'outil de longueur spécifiée
Deci 和英特尔如何在 MLPerf 上实现高达 16.8 倍的吞吐量提升和 +1.74% 的准确性提升
Use xtradiagram Diagramcontrol for drawing and controlling process graphics
Hexiaopeng: if you can go back to starting a business, you won't name the product in your own name
React query tutorial ④ - cache status and debugging tools
Quartus call & design D trigger Simulation & timing wave verification
如何正确计算导入Excel的行数(POI/NPOI)
Detailed explanation of serial port, com, UART, TTL, RS232 (485) differences
How did Tencent's technology bulls complete the overall cloud launch?
The redis keys command should be used with caution in the production environment. It is best to shield it
中断和轮询