Masterarbeit Richard Stern. Flutter App, sich mit einem Bluetooth-Gerät verbindet und Berührungen auf einem Sensor visualisiert.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

debugCounterBloc.dart 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import 'dart:async';
  2. import 'package:rxdart/rxdart.dart';
  3. import 'package:rxdart/subjects.dart';
  4. class DebugBloc {
  5. int _counter = 0;
  6. bool _debugScreenEnabled = false;
  7. static const debugSwitchValue = 3;
  8. final _incrementController = StreamController<void>();
  9. final _debugDisableController = StreamController<void>();
  10. final _debugEnabledStatus$ = BehaviorSubject<bool>();
  11. DebugBloc() {
  12. print('init: Debug BLOC');
  13. _incrementController.stream.listen((void _) {
  14. _counter = _counter + 1;
  15. print('counterBloc: debug counter = $_counter / $debugSwitchValue');
  16. if(_counter % debugSwitchValue == 0){
  17. _debugScreenEnabled = !_debugScreenEnabled;
  18. _debugEnabledStatus$.add(_debugScreenEnabled);
  19. _counter = 0;
  20. }
  21. });
  22. _debugDisableController.stream.listen((void _){
  23. if(_debugScreenEnabled){
  24. _counter = 0;
  25. _debugScreenEnabled = false;
  26. _debugEnabledStatus$.add(_debugScreenEnabled);
  27. }
  28. });
  29. }
  30. Sink<void> get debugCounterIncrement => _incrementController.sink;
  31. Sink<void> get debugDisable => _debugDisableController.sink;
  32. Stream<bool> get debugEnabledStatus$ => _debugEnabledStatus$.stream;
  33. void dispose() {
  34. _incrementController.close();
  35. _debugDisableController.close();
  36. _debugEnabledStatus$.close();
  37. }
  38. }