当前位置:网站首页>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,
);
}
}
边栏推荐
- [IELTS reading] Wang Xiwei reading P2 (reading fill in the blank)
- Pageoffice - bug modification journey
- What is the standard format of a 2000-3000 word essay for college students' classroom homework?
- There is an unknown problem in inserting data into the database
- Automated defect analysis in electron microscopic images-论文阅读笔记
- kubernetes资源对象介绍及常用命令(五)-(NFS&PV&PVC)
- Angled detection frame | calibrated depth feature for target detection (with implementation source code)
- Hundreds of continuous innovation to create free low code office tools
- Array common operation methods sorting (including ES6) and detailed use
- [shutter] Introduction to the official example of shutter Gallery (project introduction | engineering construction)
猜你喜欢

CMake基本使用

FAQ | FAQ for building applications for large screen devices

Linux Software: how to install redis service

Which websites can I search for references when writing a thesis?
![[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

ftrace工具的介绍及使用

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

Linux软件:如何安装Redis服务

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

DotNet圈里一个优秀的ORM——FreeSql
随机推荐
Should you study kubernetes?
Use Jenkins II job
经济学外文文献在哪查?
Bypass AV with golang
国外的论文在那找?
【luogu P4320】道路相遇(圆方树)
Briefly talk about other uses of operation and maintenance monitoring
Linux软件:如何安装Redis服务
Pageoffice - bug modification journey
可下载《2022年中国数字化办公市场研究报告》详解1768亿元市场
【Pulsar文档】概念和架构/Concepts and Architecture
毕业总结
What website can you find English literature on?
Sysdig analysis container system call
pod生命周期详解
helm 基础学习
LeedCode1480. Dynamic sum of one-dimensional array
论文的设计方案咋写?
使用jenkins之二Job
TypeError: Cannot read properties of undefined (reading ***)