displayValues in DropdownPreference not working
I try to use the display Name and enum values for the values. Also, I can not find an example. Is that tested? Thanks Jay
DropdownPreference(
'Debug Mode',
'debug_mode',
defaultVal: DebugKind.Sender,
values: [DebugKind.Sender, DebugKind.Receiver],
displayValues: ['Sender', 'Receiver'],
onChange: (value) {
bloc.kindSink.add(value);
},
),
Thats the error:
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
The following assertion was thrown building DropdownPreference(dirty, state: _DropdownPreferenceState#93c7e):
'package:flutter/src/material/dropdown.dart': Failed assertion: line 620 pos 15: 'items == null || items.isEmpty || value == null || items.where((DropdownMenuItem<T> item) => item.value == value).length == 1': is not true.
Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
https://github.com/flutter/flutter/issues/new?template=BUG.md
User-created ancestor of the error-causing widget was:
PreferencePage file:///C:/Projects/chkobd/lib/screens/debug/remote_debugging_screen.dart:31:28
When the exception was thrown, this was the stack:
#2 new DropdownButton (package:flutter/src/material/dropdown.dart:620:15)
#3 _DropdownPreferenceState.build (package:preferences/dropdown_preference.dart:44:17)
#4 StatefulElement.build (package:flutter/src/widgets/framework.dart:4047:27)
#5 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3941:15)
#6 Element.rebuild (package:flutter/src/widgets/framework.dart:3738:5)
...
════════════════════════════════════════════════════════════════════════════════════════════════════
Flutter
C:\Projects\chkobd>flutter doctor -v
[√] Flutter (Channel stable, v1.9.1+hotfix.5, on Microsoft Windows [Version 10.0.18362.418],
locale en-US)
• Flutter version 1.9.1+hotfix.5 at c:\sdks\flutter
• Framework revision 1aedbb1835 (6 days ago), 2019-10-17 08:37:27 -0700
• Engine revision b863200c37
• Dart version 2.5.0
[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at C:\Users\ride4\AppData\Local\Android\sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
• All Android licenses accepted.
[√] Android Studio (version 3.5)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 40.2.2
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
[√] VS Code, 32-bit edition (version 1.30.1)
• VS Code at C:\Program Files (x86)\Microsoft VS Code
• Flutter extension version 2.21.1
[√] Connected device (2 available)
• Nexus 5 • 03b71506f0b4f6b6 • android-arm • Android 6.0.1 (API 23)
• moto g 7 • ZY225G4LJN • android-arm64 • Android 9 (API 28)
• No issues found!
``