Files
MWClash/lib/common/mixin.dart
chen08209 060e1b5392 Optimize desktop view
Optimize logs, requests, connection pages

Optimize windows tray auto hide

Update core
2025-07-25 15:20:17 +08:00

45 lines
1.2 KiB
Dart

import 'package:riverpod/riverpod.dart';
mixin AutoDisposeNotifierMixin<T> on AutoDisposeNotifier<T> {
set value(T value) {
state = value;
}
@override
bool updateShouldNotify(previous, next) {
final res = super.updateShouldNotify(previous, next);
if (res) {
onUpdate(next);
}
return res;
}
void onUpdate(T value) {}
}
// mixin PageMixin<T extends StatefulWidget> on State<T> {
// initPageState() {
// WidgetsBinding.instance.addPostFrameCallback((_) {
// final commonScaffoldState = context.commonScaffoldState;
// commonScaffoldState?.actions = actions;
// commonScaffoldState?.floatingActionButton = floatingActionButton;
// commonScaffoldState?.onKeywordsUpdate = onKeywordsUpdate;
// commonScaffoldState?.updateSearchState(
// (_) => onSearch != null
// ? AppBarSearchState(
// onSearch: onSearch!,
// )
// : null,
// );
// });
// }
//
// List<Widget> get actions => [];
//
// Widget? get floatingActionButton => null;
//
// Function(String)? get onSearch => null;
//
// Function(List<String>)? get onKeywordsUpdate => null;
// }