失败断言:第6276行POS 12:' child == _CHILD':不正确。当在颤音中使用溪流

发布于 2025-01-18 08:50:48 字数 1455 浏览 5 评论 0原文

我的状态有一个基于提供程序的流控制器


final PanelController panelController = PanelController();
StreamController<bool> closeToDstStream = StreamController<bool>();

  void showPanelOnCloseToDst(LocationData locationData, dynamic smartCheckData,
      UserRepository userRepository, UserprofileBloc userprofileBloc) async {

     ...some other irrelevant code here...

    if (distanceFromDestination < 100) {
      closeToDstStream.add(true);
      if(panelController.isPanelClosed){
      panelController.show();
      }

    } else {
      closeToDstStream.add(false);
    }

  }

然后在 ui 上我使用控制器提供的流,如下所示

 OrderFlowProvider _orderFlow = Provider.of<OrderFlowProvider>(context);

...other widgets here...

StreamBuilder<bool>(
   stream: _orderFlow.closeToDstStream.stream,
   builder: (context, snapshot) {
        bool enabled = snapshot.hasData && snapshot.data;
        return SharedButton(
          text: "Arrived at Pick Up${snapshot.data}",
          disable: !enabled,
        onTap: () async {}


                          })

这个小部件位于 这个包可以显示或隐藏。当这个小部件最初加载时,一切都很好。 但是当我隐藏然后尝试使用上面的代码再次显示它时,它给我带来了错误

Another exception was thrown: 'package:flutter/src/widgets/framework.dart': Failed
assertion: line 6276 pos 12: 'child == _child': is not true.

I have a stream controller in my state that is based off provider


final PanelController panelController = PanelController();
StreamController<bool> closeToDstStream = StreamController<bool>();

  void showPanelOnCloseToDst(LocationData locationData, dynamic smartCheckData,
      UserRepository userRepository, UserprofileBloc userprofileBloc) async {

     ...some other irrelevant code here...

    if (distanceFromDestination < 100) {
      closeToDstStream.add(true);
      if(panelController.isPanelClosed){
      panelController.show();
      }

    } else {
      closeToDstStream.add(false);
    }

  }

Then on the ui Im using the stream provided by the controller as follows

 OrderFlowProvider _orderFlow = Provider.of<OrderFlowProvider>(context);

...other widgets here...

StreamBuilder<bool>(
   stream: _orderFlow.closeToDstStream.stream,
   builder: (context, snapshot) {
        bool enabled = snapshot.hasData && snapshot.data;
        return SharedButton(
          text: "Arrived at Pick Up${snapshot.data}",
          disable: !enabled,
        onTap: () async {}


                          })

This widget is in a sliding up panel from this package that can be shown or hidden. When this widget loads initally everything is fine.
But when i hide then try to show it again using the code above from state it gets me the error

Another exception was thrown: 'package:flutter/src/widgets/framework.dart': Failed
assertion: line 6276 pos 12: 'child == _child': is not true.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文