issues
search
hhstore
/
blog
My Tech Blog: about Mojo / Rust / Golang / Python / Kotlin / Flutter / VueJS / Blockchain etc.
https://github.com/hhstore/blog/issues
295
stars
24
forks
source link
Dart Pro: Extension
#286
Open
hhstore
opened
3 years ago
hhstore
commented
3 years ago
related:
[x] xxx
[x] xxx
hhstore
commented
3 years ago
Dart 语法进阶: Extension
应用场景:
[x] 对已存在的库, 进行扩展.
[x] 非常简洁, 优雅, 高效.
[x] 有点像 Mixin, 但是
已存在的库
本身, 无感知.
[x] 无限插槽.
典型用例:
https://github.com/leisim/dartx/blob/master/lib/src/string.dart
这种扩展方式, 非常优雅.
time.dart:
https://github.com/jogboms/time.dart/blob/master/lib/src/extensions.dart
对标准库进行扩展. 且无侵入.
ref:
https://www.coder-dong.com/archives/flutterclassextension
related: