|             Line data    Source code 
       1              : import 'dart:async';
       2              : 
       3              : class CachedStreamController<T> {
       4              :   T? _value;
       5              :   Object? _lastError;
       6              :   final StreamController<T> _streamController = StreamController.broadcast();
       7              : 
       8           39 :   CachedStreamController([T? value]) : _value = value;
       9              : 
      10           66 :   T? get value => _value;
      11            0 :   Object? get lastError => _lastError;
      12           84 :   Stream<T> get stream => _streamController.stream;
      13              : 
      14           34 :   void add(T value) {
      15           34 :     _value = value;
      16           68 :     _streamController.add(value);
      17              :   }
      18              : 
      19            1 :   void addError(Object error, [StackTrace? stackTrace]) {
      20            2 :     _lastError = value;
      21            2 :     _streamController.addError(error, stackTrace);
      22              :   }
      23              : 
      24            3 :   Future close() => _streamController.close();
      25            0 :   bool get isClosed => _streamController.isClosed;
      26              : }
         |