mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 13:58:47 +00:00
Refactor Simplistic_Editor (#1375)
* refactor out FormattingToolbar and TextEditingDeltaHistoryView from main` * replace togglebuttonstatemanager and texteditingdeltahistorymanager with appstatemanager * fix up tests * clean up * Add ReplacementTextEditingController to AppState * formatting * `dart format` Co-authored-by: Renzo Olivares <roliv@google.com> Co-authored-by: Brett Morgan <brettmorgan@google.com>
This commit is contained in:
27
simplistic_editor/lib/app_state_manager.dart
Normal file
27
simplistic_editor/lib/app_state_manager.dart
Normal file
@@ -0,0 +1,27 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import 'app_state.dart';
|
||||
|
||||
class AppStateManager extends InheritedWidget {
|
||||
const AppStateManager({
|
||||
super.key,
|
||||
required super.child,
|
||||
required AppState state,
|
||||
}) : _appState = state;
|
||||
|
||||
static AppStateManager of(BuildContext context) {
|
||||
final AppStateManager? result =
|
||||
context.dependOnInheritedWidgetOfExactType<AppStateManager>();
|
||||
assert(result != null, 'No AppStateManager found in context');
|
||||
return result!;
|
||||
}
|
||||
|
||||
final AppState _appState;
|
||||
|
||||
AppState get appState => _appState;
|
||||
|
||||
@override
|
||||
bool updateShouldNotify(AppStateManager oldWidget) {
|
||||
return appState != oldWidget.appState;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user