diff --git a/CHANGELOG.md b/CHANGELOG.md index 68300a5..5058b66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,3 +21,7 @@ Favorite and initial selection can be one of code or dial code ## 0.1.3 Favorite and initial selection can be one of code or dial code + +## 0.2.0 + +Now onChanged has a full CElement as argument and not only a string. (issue #4) \ No newline at end of file diff --git a/README.md b/README.md index 9e6f509..08b7d22 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Pub](https://img.shields.io/badge/Pub-0.1.3-orange.svg)](https://pub.dartlang.org/packages/country_code_picker) +[![Pub](https://img.shields.io/badge/Pub-0.2.0-orange.svg)](https://pub.dartlang.org/packages/country_code_picker) # country_code_picker diff --git a/lib/country_code_picker.dart b/lib/country_code_picker.dart index 858a50e..c63761b 100644 --- a/lib/country_code_picker.dart +++ b/lib/country_code_picker.dart @@ -1,12 +1,12 @@ library country_code_picker; -import 'package:country_code_picker/country_codes.dart'; -import 'package:flutter/material.dart'; -import 'package:country_code_picker/selection_dialog.dart'; import 'package:country_code_picker/celement.dart'; +import 'package:country_code_picker/country_codes.dart'; +import 'package:country_code_picker/selection_dialog.dart'; +import 'package:flutter/material.dart'; class CountryCodePicker extends StatefulWidget { - final Function(String) onChanged; + final Function(CElement) onChanged; final String initialSelection; final List favorite; @@ -45,8 +45,9 @@ class _CountryCodePickerState extends State { initState() { if (widget.initialSelection != null) { selectedItem = elements.firstWhere( - (e) => (e.code.toUpperCase() == widget.initialSelection.toUpperCase()) || - (e.dialCode == widget.initialSelection.toString()), + (e) => + (e.code.toUpperCase() == widget.initialSelection.toUpperCase()) || + (e.dialCode == widget.initialSelection.toString()), orElse: () => elements[0]); } else { selectedItem = elements[0]; @@ -54,12 +55,10 @@ class _CountryCodePickerState extends State { favoriteElements = elements .where((e) => - widget.favorite.firstWhere( - (f) => e.code == f.toUpperCase() || e.dialCode == f.toString(), - orElse: () => null) != + widget.favorite + .firstWhere((f) => e.code == f.toUpperCase() || e.dialCode == f.toString(), orElse: () => null) != null) .toList(); - print(favoriteElements); super.initState(); } @@ -72,8 +71,9 @@ class _CountryCodePickerState extends State { setState(() { selectedItem = e; }); + if (widget.onChanged != null) { - widget.onChanged(e.dialCode); + widget.onChanged(e); } } }); diff --git a/pubspec.yaml b/pubspec.yaml index e7b366e..f04b8f8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: country_code_picker description: A flutter package for showing a country code selector. -version: 0.1.3 +version: 0.2.0 author: Salvatore-Giordano homepage: https://github.com/Salvatore-Giordano/CountryCodePicker @@ -9,7 +9,4 @@ environment: dependencies: flutter: - sdk: flutter - -dev_dependencies: - test: ^0.12.0 + sdk: flutter \ No newline at end of file