缺少InheritedWidget.updateShouldNotify的具体实现。

问题描述 投票:0回答:1

我正在遵循一个flutter教程,这是一个老的,所以我已经不得不做出改变,因为在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个回答
0
投票

你的代码中有一个错别字 updateSouldNotify 应是 updateShouldNotify . 这应该可以解决这个问题。

flutter文档中有一个 例子 .

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

© www.soinside.com 2019 - 2024. All rights reserved.