Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

建议添加 intoInkWell #9

Open
cdhigh opened this issue May 5, 2020 · 3 comments
Open

建议添加 intoInkWell #9

cdhigh opened this issue May 5, 2020 · 3 comments
Labels
good first issue Good for newcomers

Comments

@cdhigh
Copy link

cdhigh commented May 5, 2020

我超爱此插件,说是最爱的一点都不过分,写出来的代码超级整洁。
在这里想提一个建议,因为我的应用中我的手势检测都使用 InkWell,而不是GestureDetector,
InkWell可以完全代替GestureDetector,因为InkWell有良好的视觉反馈,而GestureDetector缺少有效的反馈。
你的package里面有 intoGestureDetector,但是缺少 intoInkWell,如果能添加的话,我就不用保存我自己修改的版本了,这样就无法顺利升级到更高的版本。

@luckybilly
Copy link
Owner

@cdhigh 很高兴这个package能帮到你

flutter的widget数量有三百多个,这个package的主要作用是为大家提供另一种flutter布局编写的思路

在实际使用过程中如果发现自己需要使用的widget未包含在内,有3种解决方案:

第1种: 使用Constructor(widget_chain支持与构造方法混用)

第2种:copy本项目的源码到本地,继续添加自己需要的widget到 widget_extensions.dart

第3种(推荐):

  1. 本地新建一个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,
    );
  }
}
  1. 在需要使用的地方import这个新建的dart文件(代替原来的import 'package:widget_chain/widget_chain.dart')
import 'my_widget_chain.dart'

@luckybilly luckybilly added the good first issue Good for newcomers label May 6, 2020
@cdhigh
Copy link
Author

cdhigh commented May 6, 2020

是的,因为很多Widget都不包含,所以一般都是混合Constructor使用的,其他的Widget我都没有提issue。
只是我使用InkWell太多,而且InkWell确实好用,我相信很多人都会使用InkWell代替GestureDetector的,所以希望能合入主分支,而自己不需要再维护一个my_xxx.dart之类的。
如果你不考虑将其合入的话,我会继续目前的方式使用InkWell,还是谢谢你的创意和贡献。

@cdhigh
Copy link
Author

cdhigh commented May 6, 2020

额外的,我写在这里,如果有你的支持者看到的话,可以帮助其他人。
关于Dart扩展函数的创意Package,除了 widget_chain 外,另一个我很喜欢的就是
https://github.com/marcglasberg/i18n_extension
flutter的默认国际化方案我一点都不喜欢,需要每个字符串都要额外取一个名字,取一个好名字本来就是程序员万年头疼的事情,而在读代码时不直观,看不到对应的字符串,靠名字去猜,自己写的话还好,别人写的有时候还猜错了(前面说的,好名字可遇而不可求),IDE跳来跳去就为了一个字符串?
使用此Package就可以将字符串留在代码中,才是符合人性的。
widget_chain 和 i18n_extension 这两个package是我的左膀右臂~~~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants