Comments (9)
This was whack. I tried every solution and the thing i finally landed on was pretty much a better implementation of the PR i made for super_tooltip like a year ago.
Anyways, the controller is just a ValueNotifier that looks like a redux action. Once it changes its action, I have a listener on it in the widget that will fire off the correct callback according to the action. This solution however correctly handles the animation time between showing/hiding tooltips unlike my old PR.
Let me know what you think ! The controller is really simple at the minute but it can be exanded.
I'll add full docs once it's been tested. To test, use
just_the_tooltip: 0.0.6-dev
and provide a controller like any other widget
final controller = JustTheController();
JustTheTooltip(
controller: controller,
// ...
)
await controller.showTooltip();
await controller.hideTooltip();
I haven't thought super hard about what would happen when there's competing events or other edge cases so it might be off. Let me know
from just_the_tooltip.
Was actually thinking this myself ! I'll definitely add something like this in the near future
from just_the_tooltip.
My main struggle with this is whether I want a controller or something more declarative. The declarative option would just involve properties on the tip like isVisible
and you would hold those properties on the state of the widget that has the tooltip or an ancestor.
If you could point me to a really intuitive API of a different tooltip package that has worked for you we'll in the past, I'd consider it. It might even be from the React/Vue world.
My main gripe against controllers is that it's another thing for the user to remember to dispose and I personally never liked the non-granular update process around ChnageNotifiers although that's not really the issue.
from just_the_tooltip.
@Nolence I also would like to add hiding the tooltip programatically. Let's say I want to show a tooltip for a fixed Duration.
After the duration is passed I want to hide it programatically without the user pressing the screen. This feature is very important for me :)
from just_the_tooltip.
I understand your concern perfectly. Personally I would benefit from a controller architecture.
However for this issue, we can add optional isShown
and showAndHideFadeTransitionDuration
fields.
from just_the_tooltip.
I'm a little dumb as to how this controller will work. I took a look at an old PR I think I wrote for super_tooltip
and I naively wrote an event based controller not at all hooked up to the actual widget. Not even sure it awaits the transition.
Do you know of any resources to find out how to cleanly wire a controller to a Widget? I looked at ScrollController and PageController and those are kinda chaotic. Their animateTo
's and stuff are also like one liners that don't make any sense to me.
One option I thought is to pass all of my widget callbacks to the controller and just call them in the controller. That might work but I've never seen anyone else do it
(i.e. pass in the method _showTooltip as a property to the controller and then inside the controller's showTooltip, i just call _showTooltip)
https://github.com/Nolence/just_the_tooltip/blob/0ed778c4d698689f7720a5618c3c94f776c82397/lib/src/just_the_tooltip.dart#L169
controller code:
https://github.com/Nolence/just_the_tooltip/blob/0ed778c4d698689f7720a5618c3c94f776c82397/lib/src/models/just_the_controller.dart#L3
from just_the_tooltip.
I personally find this kind of a controller implementation easier: https://github.com/akshathjain/sliding_up_panel/blob/master/lib/src/panel.dart
It is a simple controller class which keeps the state class as a variable inside.
from just_the_tooltip.
I really like how clean that panel solution is. One thing that concerns me though is that they don't dispose anything. It's just a class that holds a reference to state. I can imagine a situation where the controller can become out of date with the internal state. It looks like onDispose, they don't invalidate anything on the controller so I think you could get some weird results if this was used wrong.
I found this SO answer https://stackoverflow.com/questions/63954710/creating-a-custom-controller-in-flutter That kind of discusses what we're talking about here. Someone else seems to have done what I suggested here by passing in the functions to the class.
I agree with Schnodderbalken's answer though saying this might be an anti-pattern though. I would also like something closer to a ValueNotifier.
That said, in my case, it's a bit harder as I use just about every lifecycle, require a delegate to determine some state and have listeners I need to constantly worry about -- all of which were better off connected to a widget and not being passed through to a controller.
I'll mull this over some more. I think i'll need to make a large refactor to support controllers so I don't want to jump into something right away
from just_the_tooltip.
Hi. I use showTooltip for show tooltip when change page on pageView and works, but sometimes tooltip is not shown.
If I use debugger seems to enter on funcion every times, but sometimes tooltip is not shown.
What can I do?
from just_the_tooltip.
Related Issues (20)
- Get rid of JustTheInterface
- make tooltip not disappear when hovering over the actual tooltip widget
- isModal:true makes the tooltip persistant (on previous page) when a GestureDetector of higher level pushes the navigator to a new route...
- Tooltip doesn't show up, dry layout errors. HOT 2
- Prevent the tooltip from closing on clicking on it HOT 2
- onShow not triggering correctly
- Gesture Detector in other page wont work if the page is redirected from tooltip HOT 1
- isModal does not work, if child is gestureDetector
- Just showing a simple tooltip by default?
- Bad state: This controller has not been attached to a tooltip yet. HOT 5
- Tooltip with Outline Border HOT 1
- clickable content HOT 2
- uses-material-design: true is unnecessary HOT 1
- The size of the content is too big.
- cannot show in nested navigation
- LateInitializationError: Field 'axisDirection' has not been initialized.
- Allow to pass a overlay state to the constructor.
- Controller Issue HOT 3
- Tooltip location issue when page size isn't full width HOT 1
- auto close is not work 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 just_the_tooltip.