AppFlowy/app_flowy/packages/flowy_infra/lib/notifier.dart

25 lines
436 B
Dart
Raw Normal View History

import 'package:flutter/material.dart';
class PublishNotifier<T> extends ChangeNotifier {
T? _value;
set value(T newValue) {
2021-11-11 11:56:30 +00:00
if (_value != newValue) {
_value = newValue;
notifyListeners();
}
}
T? get currentValue => _value;
void addPublishListener(void Function(T) callback) {
2021-11-11 11:56:30 +00:00
super.addListener(
() {
if (_value != null) {
callback(_value!);
}
},
);
}
}