-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Allow spell check to fail silently on unsupported platforms & spell checkers #122715
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
justinmc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I found a logic problem but I'm not sure. Otherwise just nits.
| if (configuration == null || configuration == const SpellCheckConfiguration.disabled()) { | ||
| final SpellCheckService? spellCheckService = configuration?.spellCheckService; | ||
| final bool spellCheckServiceIsConfigured = spellCheckService != null || spellCheckService == null && WidgetsBinding.instance.platformDispatcher.nativeSpellCheckServiceDefined; | ||
| if (configuration == null || configuration == const SpellCheckConfiguration.disabled() || !spellCheckServiceIsConfigured) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the logic might be off here, but tell me if I'm wrong... If configuration is null, but WidgetsBinding.instance.platformDispatcher.nativeSpellCheckServiceDefined is true, then this will return SpellCheckConfiguration.disabled(). Is that right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is right and I believe that's what we want because we don't want the spell check to be enabled by default. A configuration (even if it's just SpellCheckConfiguration()) must be specified for it to be enabled at this point.
|
|
||
| testWidgets( | ||
| 'Error thrown when spell check enabled but no default spell check service available', | ||
| 'Spell check disabled when spell check enabled but no default spell check service available', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Spell check disabled when spell check enabled" is contradictory, maybe instead say: "Spell check disabled when spellCheckConfiguration enabled"
| // a native spell checker must be supported. | ||
| return const SpellCheckConfiguration.disabled(); | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add a warning if configuration != null && spellCheckService == null && !WidgetsBinding.instance.platformDispatcher.nativeSpellCheckServiceDefined? Something like:
"Spell check was enabled with spellCheckConfiguration, but the current platform does not have a supported spell check service, and none was provided."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's something similar to what I'm thinking of:
flutter/packages/flutter/lib/src/widgets/navigator.dart
Lines 3527 to 3541 in 5b40de6
| assert(() { | |
| if (widget.pages.isEmpty) { | |
| FlutterError.reportError( | |
| FlutterErrorDetails( | |
| exception: FlutterError( | |
| 'The Navigator.pages must not be empty to use the ' | |
| 'Navigator.pages API', | |
| ), | |
| library: 'widget library', | |
| stack: StackTrace.current, | |
| ), | |
| ); | |
| } | |
| return true; | |
| }()); |
This will not run in production mode since it's wrapped in an assert. Also, FlutterError.reportError won't halt execution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with nits 👍
I'm assuming the customer tests just need a merge to pass.
Removes assertion error for cases where platform/native spell checker is not supported and instead, allows spell check to fail silently for these cases.
Fixes #120611.
Pre-launch Checklist
///).