当前位置:网站首页>Extension of flutter
Extension of flutter
2022-07-03 00:35:00 【Jian Zhao ZJ】
Extend the application of basic data types
extension IntExtension on int {
toSay() {
print('IntExtension Hello~');
}
}
extension StringExtension1 on String {
// The string is converted to Color object
toColor() {
var hexColor = this.replaceAll("#", "");
if (hexColor.length == 6) {
hexColor = "FF" + hexColor;
}
if (hexColor.length == 8) {
return Color(int.parse("0x$hexColor"));
}
}
// character string int
parseInt() {
return int.parse(this);
}
}
Application of extension in class
extension DateTimeExtension on DateTime {
toFormatString() {
//DateFormat dateFormat = new DateFormat("yyyy-MM-dd HH:mm:ss");
return "to_format_string";
}
}
Application of extensions in generics
extension HclList<T> on List<T> {
// Extended attributes
int get doubleLength => length * 2;
// Extended operation symbol
List<T> operator -() => reversed.toList();
// A linked list is divided into two
List<List<T>> split(int at) => <List<T>>[sublist(0, at), sublist(at)];
}
Expand on Widget Application in
extension HclWidget on Widget {
Widget marginAll(double margin) {
return Container(
alignment: Alignment.center,
margin: EdgeInsets.all(margin),
child: this,
);
}
}
边栏推荐
- Array de duplication
- FAQ | FAQ for building applications for large screen devices
- 多进程编程(二):管道
- The "2022 China Digital Office Market Research Report" can be downloaded to explain the 176.8 billion yuan market in detail
- Go自定义排序
- 论文的设计方案咋写?
- Markdown使用教程
- 大学生课堂作业2000~3000字的小论文,标准格式是什么?
- AttributeError: ‘tuple‘ object has no attribute ‘layer‘问题解决
- Bypass AV with golang
猜你喜欢
Automated defect analysis in electronic microscopic images
AttributeError: ‘tuple‘ object has no attribute ‘layer‘问题解决
setInterval定时器在ie不生效原因之一:回调的是箭头函数
TypeError: Cannot read properties of undefined (reading ***)
Gan model architecture in mm
百数不断创新,打造自由的低代码办公工具
Seckill system design
字符设备注册常用的两种方法和步骤
An excellent orm in dotnet circle -- FreeSQL
Rust字符串切片、结构体和枚举类
随机推荐
多进程编程(二):管道
Logback configuration file
Mutual exclusion and synchronization of threads
Multi process programming (III): message queue
Explain in detail the significance of the contour topology matrix obtained by using the contour detection function findcontours() of OpenCV, and how to draw the contour topology map with the contour t
Form form instantiation
大学生课堂作业2000~3000字的小论文,标准格式是什么?
【JetCache】JetCache的配置说明和注解属性说明
kubernetes编写yml简单入门
Shell 实现文件基本操作(切割、排序、去重)
【雅思阅读】王希伟阅读P2(阅读填空)
Cmake basic use
Go custom sort
mm中的GAN模型架构
What are the recommended thesis translation software?
为什么网站打开速度慢?
Automated defect analysis in electron microscopic images-论文阅读笔记
微信小程序获取某个元素的信息(高、宽等),并将px转换为rpx。
FAQ | FAQ for building applications for large screen devices
Don't want teachers to see themselves with cameras in online classes? Virtual camera you deserve!