扑飞镖:didChangeDependencies无限运行

时间:2020-02-03 11:26:18

标签: flutter dart

我正在尝试获取函数中流的状态,并且如果该流的值为true,则基于该导航器转到其他屏幕,否则将保留在当前屏幕上。我创建了一个异步函数来获取最新的流数据。但是小部件正在重建无穷大

  @override
  void didChangeDependencies() {
    super.didChangeDependencies();
    _bloc = Provider.of(context).fetch(AuthBloc);
    _sbloc = Provider.of(context).fetch(StoresBloc);
    getCurrentStoreStatus();
    print('after : ${_sbloc.getStoreStatus}');

  }

获取

  getCurrentStoreStatus() async{
    Embedded storeStatus = await _sbloc.getCurrentStore();
    if(_sbloc.getStoreStatus == true){
      Navigator.pushNamed(context, CustomerRatingsScreen.id);
    }
    return storeStatus;
  }

输出是after:true的连续打印和init之后的null的连续打印。需要了解我在做什么错。

0 个答案:

没有答案