'How to recieve a message in the bloc getter changeMessage (which is actualy works as a setter)?

There is a bloc

  final _message = BehaviorSubject<String>();
  Stream<String> get message => _message.stream;

  Function(String) get changeMessage {
    if (value == 'error') { // value is undefined here - how to get it?
      _message.sink.addError('error message');
    }

    return _message.sink.add;
  }

and in a service method I run changeMessage on the bloc

  ... } catch (e) {
      aBloc.changeMessage('error');
      return null;
  }

Is it possible to get passed value error in the bloc getter changeMessage? It will give a condition to put error in the sink.

Later it the view it give the ability to obtaine snapshot.hasError condition.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source