当前位置:网站首页>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,
);
}
}
边栏推荐
- MySQL 23 classic interview hanging interviewer
- Luogu_ P2010 [noip2016 popularization group] reply date_ Half enumeration
- What are the recommended thesis translation software?
- 毕业总结
- Rust字符串切片、结构体和枚举类
- Andorid 获取系统标题栏高度
- 数组常用操作方法整理(包含es6)及详细使用
- An excellent orm in dotnet circle -- FreeSQL
- NC50965 Largest Rectangle in a Histogram
- 【Pulsar文档】概念和架构/Concepts and Architecture
猜你喜欢

Architecture: load balancing

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

What are the recommended thesis translation software?

Architecture: database architecture design

Understanding and application of least square method

有哪些比较推荐的论文翻译软件?

University of Toronto:Anthony Coache | 深度强化学习的条件可诱导动态风险度量
![[IELTS reading] Wang Xiwei reading P1 (reading judgment question)](/img/ee/540661fcb2cf1cf1eb15e2026c997a.png)
[IELTS reading] Wang Xiwei reading P1 (reading judgment question)

写论文可以去哪些网站搜索参考文献?
![[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
随机推荐
Chapter 4 of getting started with MySQL: data types stored in data tables
多进程编程(一):基本概念
Automated defect analysis in electronic microscopic images
Luogu_ P2010 [noip2016 popularization group] reply date_ Half enumeration
[IELTS reading] Wang Xiwei reading P2 (reading fill in the blank)
Basic use of shell script
redis21道经典面试题,极限拉扯面试官
form表单实例化
Pat 1030 travel plan (30 points) (unfinished)
NC24325 [USACO 2012 Mar S]Flowerpot
Introduction of UART, RS232, RS485, I2C and SPI
JSON conversion tool class
Multiprocess programming (II): Pipeline
NC50965 Largest Rectangle in a Histogram
How to write the design scheme of the thesis?
Feature Engineering: summary of common feature transformation methods
Cmake basic use
Don't want teachers to see themselves with cameras in online classes? Virtual camera you deserve!
Markdown使用教程
可下载《2022年中国数字化办公市场研究报告》详解1768亿元市场