我有一个州级
class ListScreenState extends State<ListScreen>...
Run Code Online (Sandbox Code Playgroud)
我想使用 AutomaticKeepAliveClientMixin(以防止处理这些屏幕的 TabBar)和 TickerProviderStateMixin,因为我有需要它的动画控制器。但是当我把两个 mixin 都放在这个类中时,出现了一个错误:
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)
Run Code Online (Sandbox Code Playgroud)
我真的找不到关于如何在一个班级中使用 mixin 的好解释。任何帮助表示赞赏。
这是完整的代码:
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: …Run Code Online (Sandbox Code Playgroud)