Allow spell check to fail silently on unsupported platforms & spell checkers#122715
Allow spell check to fail silently on unsupported platforms & spell checkers#122715auto-submit[bot] merged 12 commits intoflutter:masterfrom
Conversation
justinmc
left a comment
There was a problem hiding this comment.
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.
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.
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.
"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.
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.
Here's something similar to what I'm thinking of:
flutter/packages/flutter/lib/src/widgets/navigator.dart
Lines 3527 to 3541 in 5b40de6
This will not run in production mode since it's wrapped in an assert. Also, FlutterError.reportError won't halt execution.
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
///).