小编Roh*_*han的帖子

SingleTickerProviderStateMixin 和自定义 mixin

我是 Flutter 和 Dart 的新手,Google 无法帮助我解决这个问题。

假设我有这个:

class _MapPageState extends BaseState<MapPage> with SingleTickerProviderStateMixin

我想在此之上添加另一个 mixin (BasePage),其中包含可重用的应用程序栏、抽屉等。本文介绍了布局。

我知道这是不可能的,我的 IDE 会抛出一个错误,告诉我集成它们,但我不知道如何集成。有解决办法吗?我需要SingleTickerProviderStateMixin,因为我正在使用的动画控制器需要它。

如果需要的话,这是自定义 mixin 代码:

abstract class Base extends StatefulWidget {
  Base({Key key}) : super(key: key);
}

abstract class BaseState<Page extends Base> extends State<Page> {
  String screenName();
}

mixin BasePage<Page extends Base> on BaseState<Page> {

  MapFunctions functions = MapFunctions();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text('Guidey'),
          backgroundColor: Colors.deepOrangeAccent,
          centerTitle: true,
        ),
        drawer: Theme(
          data: Theme.of(context).copyWith( …
Run Code Online (Sandbox Code Playgroud)

mixins dart flutter

2
推荐指数
1
解决办法
4081
查看次数

标签 统计

dart ×1

flutter ×1

mixins ×1