Closed mtkgeek closed 3 years ago
This could be a pretty cool new feature added to this package, but it will require a significant rewrite of the whole thing. Maybe I'll have some time to do this, but I'm open to PRs :)
There are a couple of ways you could do it which may not be that invasive:
createArrowWidget(BuildContext context)
expand_text.dart#L209.typedef ExpandOnTap = void Function([DragEndDetails? dragDetails])
typedef ExpandWidgetBuilder = Widget Function(BuildContext context, ExpandText widget, ExpandOnTap onTap)
When building my own classes I tend to use 1 when I have full control of what could be changing in the super classes. For a library it's better to use 2 to give you more control over what becomes API and is easier to implement for an end user.
Hey! This makes sense and you guidelines @JamesMcIntosh looks cool, I'll take a look a this in the coming days!
So the final solution is ready @JamesMcIntosh ! I've added a new IndicatorBuilder
typedef which you can use to build your own indicator. The VoidCallback
is the interal onTap
method, and the bool
tell you if the widget is on 'expanded` mode or not.
typedef IndicatorBuilder = Widget Function(
BuildContext,
VoidCallback,
bool,
);
You can now pass a new argument to both 'expand' wigdets, called indicatorBuilder
. This new widget will replace the default expansion arrow.
indicatorBuilder: (context, onTap, expanded) => InkWell(
child: FlutterLogo(
style: expanded
? FlutterLogoStyle.horizontal
: FlutterLogoStyle.stacked,
size: 50,
),
onTap: onTap,
),
I think this is the best way of bring to developers the ability to construct the best indicator they can, and by maintaining the ease of use and stability this package offers today.
If you have any feedback on this, please let me know!
Nice and clean!
I think I suggested having the widget/state as part of the type because you may wish to access these:
collapsedHint, expandedHint, arrowPadding, arrowColor, arrowSize, icon, hintTextStyle, expandArrowStyle, capitalArrowtext
If you're making the statement that these are not needed when creating a custom widget, which looks to be sensible, then it's all good.
Hi, great package. Is there a way i can use a widget like a button as my tap widget instead of just a text and/or an icon?