找不到提供者 - Flutter

Could not find a Provider - Flutter

我想为我的 DecksList 小部件提供流,所以我在 MyApp 中初始化了一个提供程序。它抛出一个 ProviderNotFoundError。这种行为的原因是什么?

I/flutter (27768): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (27768): The following ProviderNotFoundError was thrown building NotificationListener<KeepAliveNotification>:
I/flutter (27768): Error: Could not find the correct Provider<Stream<List<Deck>>> above this DecksList Widget

打开图片查看 MyApp 小部件: app widget

Home 小部件中的 DecksList:

class DecksList extends StatefulWidget {
  @override
  _DecksListState createState() => _DecksListState();
}

class _DecksListState extends State<DecksList> {
  Stream<List<Deck>> decks;

  @override
  void didChangeDependencies() {
    super.didChangeDependencies();
    decks = Provider.of<Stream<List<Deck>>>(context);
  }

  @override
  Widget build(BuildContext context) {
    return StreamBuilder<List<Deck>>(
        stream: decks,
        builder: (context, snapshot) {
          final decksList = snapshot.data ?? List();
          return ListView.builder(
//          to scroll lists together
            physics: ClampingScrollPhysics(),
            shrinkWrap: true,
            itemCount: decksList.length,
            itemBuilder: (BuildContext context, int index) {
              final Deck itemDeck = decksList[index];
              return DeckTile(
                deckItem: itemDeck,
                onPressed: () {
                  Navigator.push(context,
                      CupertinoPageRoute(builder: (BuildContext context) {
                    return FlashcardsDeck(
                      deckId: itemDeck.id,
                    );
                  }));
                },
                onLongPress: () {},
              );
            },
          );
        });
  }
}

问题出在摩尔图书馆。 这是一个问题https://github.com/simolus3/moor/issues/329