当前位置:网站首页>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,
);
}
}
边栏推荐
- 数组常用操作方法整理(包含es6)及详细使用
- Array de duplication
- Multiprocess programming (V): semaphores
- 论文的英文文献在哪找(除了知网)?
- 多进程编程(一):基本概念
- Basic 10 of C language: array and pointer
- Luogu_ P1149 [noip2008 improvement group] matchstick equation_ Enumeration and tabulation
- JSON conversion tool class
- Basic use of shell script
- Thinkadmin V6 arbitrary file read vulnerability (cve-2020-25540)
猜你喜欢

Architecture: database architecture design

Solution to the problem of abnormal display of PDF exported Chinese documents of confluence
![[shutter] Introduction to the official example of shutter Gallery (learning example | email application | retail application | wealth management application | travel application | news application | a](/img/f2/f3b8899aa774dd32006c5928d370f1.gif)
[shutter] Introduction to the official example of shutter Gallery (learning example | email application | retail application | wealth management application | travel application | news application | a

Which software can translate an English paper in its entirety?

The "2022 China Digital Office Market Research Report" can be downloaded to explain the 176.8 billion yuan market in detail

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

Shell脚本基本使用

Where can I find the English literature of the thesis (except HowNet)?

布隆过滤器

写论文可以去哪些网站搜索参考文献?
随机推荐
Multiprocess programming (4): shared memory
Kubernetes simple introduction to writing YML
Array de duplication
What is the standard format of a 2000-3000 word essay for college students' classroom homework?
AcWing_ 188. Warrior cattle_ bfs
Detailed explanation of pod life cycle
Why is the website slow to open?
多进程编程(五):信号量
MySQL 23 classic interview hanging interviewer
JSON转换工具类
Nc50528 sliding window
【雅思阅读】王希伟阅读P1(阅读判断题)
Go custom sort
Which websites can I search for references when writing a thesis?
关于XML一些介绍和注意事项
毕业总结
kubernetes编写yml简单入门
[MCU project training] eight way answering machine
Seckill system design
How to write the design scheme of the thesis?