add some documentation
This commit is contained in:
@@ -1,23 +1,27 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
/// Country element. This is the element that contains all the information
|
||||
class CElement {
|
||||
/// the name of the country
|
||||
String name;
|
||||
|
||||
/// the flag of the country
|
||||
String flag;
|
||||
|
||||
/// the country code (IT,AF..)
|
||||
String code;
|
||||
|
||||
/// the dial code (+39,+93..)
|
||||
String dialCode;
|
||||
|
||||
CElement({this.name, this.flag, this.code, this.dialCode});
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return defaultTargetPlatform == TargetPlatform.android
|
||||
? "$flag $dialCode"
|
||||
: dialCode;
|
||||
return defaultTargetPlatform == TargetPlatform.android ? "$flag $dialCode" : dialCode;
|
||||
}
|
||||
|
||||
String toLongString() {
|
||||
return defaultTargetPlatform == TargetPlatform.android
|
||||
? "$flag $dialCode $name"
|
||||
: "$dialCode $name";
|
||||
return defaultTargetPlatform == TargetPlatform.android ? "$flag $dialCode $name" : "$dialCode $name";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,8 +55,9 @@ class _CountryCodePickerState extends State<CountryCodePicker> {
|
||||
|
||||
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();
|
||||
super.initState();
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import 'package:flutter/material.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 {
|
||||
final List<CElement> elements;
|
||||
|
||||
/// elements passed as favorite
|
||||
final List<CElement> favoriteElements;
|
||||
|
||||
SelectionDialog(this.elements, this.favoriteElements);
|
||||
@@ -12,6 +15,7 @@ class SelectionDialog extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _SelectionDialogState extends State<SelectionDialog> {
|
||||
/// this is useful for filtering purpose
|
||||
List<CElement> showedElements = [];
|
||||
|
||||
@override
|
||||
@@ -56,10 +60,7 @@ class _SelectionDialogState extends State<SelectionDialog> {
|
||||
s = s.toUpperCase();
|
||||
setState(() {
|
||||
showedElements = widget.elements
|
||||
.where((e) =>
|
||||
e.code.contains(s) ||
|
||||
e.dialCode.contains(s) ||
|
||||
e.name.toUpperCase().contains(s))
|
||||
.where((e) => e.code.contains(s) || e.dialCode.contains(s) || e.name.toUpperCase().contains(s))
|
||||
.toList();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user