【问题标题】:missing concrete implementation of InheritedWidget.updateShouldNotify缺少 InheritedWidget.updateShouldNotify 的具体实现
【发布时间】:2020-10-03 02:28:10
【问题描述】:

我正在关注一个颤振教程,它是一个旧教程,所以我已经不得不根据 dart 和一些库中的更改进行更改,但是我收到了这个错误,教程中的那个人在那里没有遇到这样的错误。 PS:它是“StoriesProvider 被定义”的唯一地方

class StoriesProvider extends InheritedWidget { //Missing concrete implementation of InheritedWidget.updateShouldNotify here
  final StoriesBloc bloc;

  StoriesProvider({Key key, Widget child})
      : bloc = StoriesBloc(),
        super(key: key, child: child);

  bool updateSouldNotify(_) => true;

  static StoriesBloc of(BuildContext context) {
    return (context.dependOnInheritedWidgetOfExactType<StoriesProvider>(
            ))
        .bloc;
  }
}

【问题讨论】:

    标签: flutter dart implementation concrete


    【解决方案1】:

    您的代码中有错字 updateSouldNotify 应该是 updateShouldNotify 。这应该可以解决问题。

    flutter 文档有一个 Example

    @override bool updateShouldNotify(FrogColor old) => color != old.color;

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-06-14
      • 2020-06-11
      • 2019-05-14
      • 2020-06-27
      • 2021-11-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多