当前位置:网站首页>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,
);
}
}
边栏推荐
猜你喜欢

One of the reasons why setinterval timer does not take effect in ie: the callback is the arrow function

字符设备注册常用的两种方法和步骤

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

TypeError: Cannot read properties of undefined (reading ***)

Attributeerror: 'tuple' object has no attribute 'layer' problem solving

详解用OpenCV的轮廓检测函数findContours()得到的轮廓拓扑结构(hiararchy)矩阵的意义、以及怎样用轮廓拓扑结构矩阵绘制轮廓拓扑结构图

Which websites can I search for references when writing a thesis?

Two common methods and steps of character device registration

Bigder:32/100 测试发现的bug开发认为不是bug怎么处理

Redis21 classic interview questions, extreme pull interviewer
随机推荐
helm 基础学习
[shutter] Introduction to the official example of shutter Gallery (learning example | email application | retail application | wealth management application | travel application | news application | a
Thinkadmin V6 arbitrary file read vulnerability (cve-2020-25540)
How to write the design scheme of the thesis?
What are the recommended thesis translation software?
The "2022 China Digital Office Market Research Report" can be downloaded to explain the 176.8 billion yuan market in detail
ftrace工具的介绍及使用
Which websites can I search for references when writing a thesis?
毕业总结
Some introduction and precautions about XML
Pageoffice - bug modification journey
pageoffice-之bug修改之旅
Chapter 4 of getting started with MySQL: data types stored in data tables
Introduction of UART, RS232, RS485, I2C and SPI
Understanding and application of least square method
About the practice topic of screen related to unity screen, unity moves around a certain point inside
Blue decides red - burst CS teamserver password
百数不断创新,打造自由的低代码办公工具
Pat 1030 travel plan (30 points) (unfinished)
Don't want teachers to see themselves with cameras in online classes? Virtual camera you deserve!