1 year ago

#356501

test-img

Bright

Failed assertion: line 6276 pos 12: 'child == _child': is not true. when using StreamBuilder in flutter

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.

flutter

stream

stream-builder

0 Answers

Your Answer

Accepted video resources