mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
21 lines
375 B
Dart
21 lines
375 B
Dart
|
import 'package:flutter/material.dart';
|
||
|
|
||
|
class PublishNotifier<T> extends ChangeNotifier {
|
||
|
T? _value;
|
||
|
|
||
|
set value(T newValue) {
|
||
|
_value = newValue;
|
||
|
notifyListeners();
|
||
|
}
|
||
|
|
||
|
T? get currentValue => _value;
|
||
|
|
||
|
void addPublishListener(void Function(T) callback) {
|
||
|
super.addListener(() {
|
||
|
if (_value != null) {
|
||
|
callback(_value!);
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
}
|