Comments (3)
@cdhigh 很高兴这个package能帮到你
flutter的widget数量有三百多个,这个package的主要作用是为大家提供另一种flutter布局编写的思路
在实际使用过程中如果发现自己需要使用的widget未包含在内,有3种解决方案:
第1种: 使用Constructor(widget_chain支持与构造方法混用)
第2种:copy本项目的源码到本地,继续添加自己需要的widget到 widget_extensions.dart
中
第3种(推荐):
- 本地新建一个dart文件,如:
my_widget_chain.dart
:
export 'package:widget_chain/widget_chain.dart';
extension MyWidgetChain on Widget {
InkWell intoInkWell({
Key key,
GestureTapCallback onTap,
//others...
}) {
return InkWell(
key: key,
onTap: onTap,
//others...
child: this,
);
}
}
- 在需要使用的地方import这个新建的dart文件(代替原来的
import 'package:widget_chain/widget_chain.dart'
)
import 'my_widget_chain.dart'
from widget_chain.
是的,因为很多Widget都不包含,所以一般都是混合Constructor使用的,其他的Widget我都没有提issue。
只是我使用InkWell太多,而且InkWell确实好用,我相信很多人都会使用InkWell代替GestureDetector的,所以希望能合入主分支,而自己不需要再维护一个my_xxx.dart之类的。
如果你不考虑将其合入的话,我会继续目前的方式使用InkWell,还是谢谢你的创意和贡献。
from widget_chain.
额外的,我写在这里,如果有你的支持者看到的话,可以帮助其他人。
关于Dart扩展函数的创意Package,除了 widget_chain 外,另一个我很喜欢的就是
https://github.com/marcglasberg/i18n_extension
flutter的默认国际化方案我一点都不喜欢,需要每个字符串都要额外取一个名字,取一个好名字本来就是程序员万年头疼的事情,而在读代码时不直观,看不到对应的字符串,靠名字去猜,自己写的话还好,别人写的有时候还猜错了(前面说的,好名字可遇而不可求),IDE跳来跳去就为了一个字符串?
使用此Package就可以将字符串留在代码中,才是符合人性的。
widget_chain 和 i18n_extension 这两个package是我的左膀右臂~~~
from widget_chain.
Related Issues (7)
- 这个我试了一下 好像加上动画 会出问题 HOT 1
- extension methods intoXxx() cause rebuild for const HOT 1
- To-do-list HOT 1
- 增加新的控件 HOT 1
- android studio
- 问题意见 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from widget_chain.