Closed dodatw closed 5 months ago
That would be too specific. I don't think this is a good fit for the core package.
In any cases, chances are you want to use useTabController
, but move the hook inside your tab widget. This way no matter how many tabs you have, they would all have a unique controller.
We need to control each tab from parent, so we need to create tabcontroller at outside. For Other controller, (ex, scrollController), I can use useRef + list view handle ourself. But for TabController, it need TickerProvider, but useTickerProvider can only assign in one of TabController.
Another solution, is it possiable provide hook for List
I think my question should be how to handle indefinite number of TickerProvider in Hook. In useSingleTickerProvider, it say
throw FlutterError(
'${context.widget.runtimeType} attempted to use a useSingleTickerProvider multiple times.\n'
'A SingleTickerProviderStateMixin can only be used as a TickerProvider once. '
'If you need multiple Ticker, consider using useSingleTickerProvider multiple times '
'to create as many Tickers as needed.');
How it work in indefinite case ?
SingleTickerProviders cannot be passed to different objects. Use a different ticker provider instead. To do so, call useSingleTickerProvider multiple times.
The problem is I don't know how many useSingleTickerProvider I need when coding. It is runtime number.
Is that mean I cannot use hookWidget at this case ?
I have no plan for adding a useTabControllerList, so closing.
I have a requirement. There are an indefinite number of Tabs on my UI, so I need to have an indefinite number of TabControllers. How do I implement in HookWidget ?
It seem bad idea that add useTabController in a for loop.
I try to use useRef and handle TabController myself, but it cannot set vsync in hookwidget.
is there any good idea ?