I have a state class
class ListScreenState extends State<ListScreen>...
And I want to use AutomaticKeepAliveClientMixin (to prevent the TabBar that holds these screens from disposing of) and TickerProviderStateMixin because I have the animation controller that requires it. But when I put both mixins in this class there's an error:
error: Type parameters could not be inferred for the mixin 'TickerProviderStateMixin' because the base class implements the mixin's supertype constraint 'State<T>' in multiple conflicting ways (mixin_inference_inconsistent_matching_classes at [myapp] lib/trips/ListScreen.dart:21)
I couldn't really find a good explanation of how to use mixins in one class. Any help is appreciated.
Here's the full code:
import 'package:flutter/widgets.dart';
class ListScreen extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return ListScreenState();
}
}
class ListScreenState extends State<ListScreen>
with AutomaticKeepAliveClientMixin, TickerProviderStateMixin {
AnimationController controller;
@override
void initState() {
super.initState();
controller = AnimationController(
duration: const Duration(milliseconds: 250), vsync: this);
}
@override
bool get wantKeepAlive => true;
}
Dart specifically complains about adding TickerProviderStateMixin. If I remove AutomaticKeepAliveClientMixin, then it doesn't complain anymore.