【问题标题】:Flutter mixin with abstract classFlutter mixin 与抽象类
【发布时间】:2019-12-13 05:23:43
【问题描述】:

我有一个 mixin 和抽象类扩展 StatefulWidget。我想将我的 mixin 添加到抽象类中。

混音:

mixin MyMixin<T extends StatefulWidget> on State<T> {

 String translate(context,childKey)
{
var parentKey =  getParentLocalisationKey();
return  childKey+parentKey;
}

String getParentLocalisationKey();
 }

还有抽象类:

 abstract class BaseState<Page extends BasePage> extends State<Page>
with WidgetsBindingObserver {
 }

如何将 mixin 添加到抽象类?有什么办法吗?

【问题讨论】:

    标签: flutter dart mobile-development


    【解决方案1】:

    它在with之后的列表中:

    abstract class BaseState<Page extends BasePage> extends State<Page>
      with WidgetsBindingObserver, MyMixin<Page> {
    }
    

    【讨论】:

      猜你喜欢
      • 2011-12-27
      • 2016-07-05
      • 1970-01-01
      • 2010-10-10
      • 1970-01-01
      • 2010-10-23
      • 2020-07-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多