Skip to content
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

Bad state: No element error #11

Closed
0xecute opened this issue Jun 20, 2019 · 1 comment
Closed

Bad state: No element error #11

0xecute opened this issue Jun 20, 2019 · 1 comment

Comments

@0xecute
Copy link

0xecute commented Jun 20, 2019

Hello,
I have an error when trying to integrate your module.

In my pubspec.yaml:
dependencies:
flutter_country_picker: ^0.1.4

My code:
Country _country; ... CountryPicker( dense: false, showFlag: true, showDialingCode: false, showName: true, onChanged: (Country country) { setState(() { _country = country; }); }, selectedCountry: _country, ),

I got the following error:
09:43:07.055 2 info flutter.tools I/flutter (26704): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
09:43:07.055 3 info flutter.tools I/flutter (26704): The following StateError was thrown building CountryPicker(dirty, dependencies:
09:43:07.055 4 info flutter.tools I/flutter (26704): [_LocalizationsScope-[GlobalKey#5ca4e]]):
09:43:07.055 5 info flutter.tools I/flutter (26704): Bad state: No element
09:43:07.055 6 info flutter.tools I/flutter (26704):
09:43:07.055 7 info flutter.tools I/flutter (26704): When the exception was thrown, this was the stack:
09:43:07.055 8 info flutter.tools I/flutter (26704): #0 _ListBase&Object&ListMixin.singleWhere (dart:collection/list.dart:178:5)
09:43:07.055 9 info flutter.tools I/flutter (26704): #1 Country.findByIsoCode (package:flutter_country_picker/country.dart:1793:16)
09:43:07.055 10 info flutter.tools I/flutter (26704): #2 CountryPicker.build (package:flutter_country_picker/flutter_country_picker.dart:60:19)
09:43:07.055 11 info flutter.tools I/flutter (26704): #3 StatelessElement.build (package:flutter/src/widgets/framework.dart:3885:28)

I am on the latest flutter version, channel stable.

Thank you

@humazed
Copy link

humazed commented Jun 21, 2019

This error happened because you didn't specify an initail selection.

Country _selected = Country.SA;

@biessek biessek closed this as completed Aug 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants