add some documentation
This commit is contained in:
@@ -24,4 +24,8 @@ Favorite and initial selection can be one of code or dial code
|
|||||||
|
|
||||||
## 0.2.0
|
## 0.2.0
|
||||||
|
|
||||||
Now onChanged has a full CElement as argument and not only a string. (issue #4)
|
Now onChanged has a full CElement as argument and not only a string. (issue #4)
|
||||||
|
|
||||||
|
## 0.2.1
|
||||||
|
|
||||||
|
Added some documentation
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
[](https://pub.dartlang.org/packages/country_code_picker)
|
[](https://pub.dartlang.org/packages/country_code_picker)
|
||||||
|
|
||||||
# country_code_picker
|
# country_code_picker
|
||||||
|
|
||||||
|
|||||||
@@ -1,23 +1,27 @@
|
|||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
|
|
||||||
|
/// Country element. This is the element that contains all the information
|
||||||
class CElement {
|
class CElement {
|
||||||
|
/// the name of the country
|
||||||
String name;
|
String name;
|
||||||
|
|
||||||
|
/// the flag of the country
|
||||||
String flag;
|
String flag;
|
||||||
|
|
||||||
|
/// the country code (IT,AF..)
|
||||||
String code;
|
String code;
|
||||||
|
|
||||||
|
/// the dial code (+39,+93..)
|
||||||
String dialCode;
|
String dialCode;
|
||||||
|
|
||||||
CElement({this.name, this.flag, this.code, this.dialCode});
|
CElement({this.name, this.flag, this.code, this.dialCode});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return defaultTargetPlatform == TargetPlatform.android
|
return defaultTargetPlatform == TargetPlatform.android ? "$flag $dialCode" : dialCode;
|
||||||
? "$flag $dialCode"
|
|
||||||
: dialCode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String toLongString() {
|
String toLongString() {
|
||||||
return defaultTargetPlatform == TargetPlatform.android
|
return defaultTargetPlatform == TargetPlatform.android ? "$flag $dialCode $name" : "$dialCode $name";
|
||||||
? "$flag $dialCode $name"
|
|
||||||
: "$dialCode $name";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,8 +55,9 @@ class _CountryCodePickerState extends State<CountryCodePicker> {
|
|||||||
|
|
||||||
favoriteElements = elements
|
favoriteElements = elements
|
||||||
.where((e) =>
|
.where((e) =>
|
||||||
widget.favorite
|
widget.favorite.firstWhere(
|
||||||
.firstWhere((f) => e.code == f.toUpperCase() || e.dialCode == f.toString(), orElse: () => null) !=
|
(f) => e.code == f.toUpperCase() || e.dialCode == f.toString(),
|
||||||
|
orElse: () => null) !=
|
||||||
null)
|
null)
|
||||||
.toList();
|
.toList();
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:country_code_picker/celement.dart';
|
import 'package:country_code_picker/celement.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
/// selection dialog used for selection of the country code
|
||||||
class SelectionDialog extends StatefulWidget {
|
class SelectionDialog extends StatefulWidget {
|
||||||
final List<CElement> elements;
|
final List<CElement> elements;
|
||||||
|
|
||||||
|
/// elements passed as favorite
|
||||||
final List<CElement> favoriteElements;
|
final List<CElement> favoriteElements;
|
||||||
|
|
||||||
SelectionDialog(this.elements, this.favoriteElements);
|
SelectionDialog(this.elements, this.favoriteElements);
|
||||||
@@ -12,6 +15,7 @@ class SelectionDialog extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _SelectionDialogState extends State<SelectionDialog> {
|
class _SelectionDialogState extends State<SelectionDialog> {
|
||||||
|
/// this is useful for filtering purpose
|
||||||
List<CElement> showedElements = [];
|
List<CElement> showedElements = [];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -56,10 +60,7 @@ class _SelectionDialogState extends State<SelectionDialog> {
|
|||||||
s = s.toUpperCase();
|
s = s.toUpperCase();
|
||||||
setState(() {
|
setState(() {
|
||||||
showedElements = widget.elements
|
showedElements = widget.elements
|
||||||
.where((e) =>
|
.where((e) => e.code.contains(s) || e.dialCode.contains(s) || e.name.toUpperCase().contains(s))
|
||||||
e.code.contains(s) ||
|
|
||||||
e.dialCode.contains(s) ||
|
|
||||||
e.name.toUpperCase().contains(s))
|
|
||||||
.toList();
|
.toList();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
name: country_code_picker
|
name: country_code_picker
|
||||||
description: A flutter package for showing a country code selector.
|
description: A flutter package for showing a country code selector.
|
||||||
version: 0.2.0
|
version: 0.2.1
|
||||||
author: Salvatore-Giordano <salvatoregiordanoo@gmail.com>
|
author: Salvatore-Giordano <salvatoregiordanoo@gmail.com>
|
||||||
homepage: https://github.com/Salvatore-Giordano/CountryCodePicker
|
homepage: https://github.com/Salvatore-Giordano/CountryCodePicker
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user