From 1614174f13770e2599025493bad14e28972a2184 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Sat, 5 May 2018 11:22:54 +0200 Subject: [PATCH] add some documentation --- CHANGELOG.md | 6 +++++- README.md | 2 +- lib/celement.dart | 16 ++++++++++------ lib/country_code_picker.dart | 5 +++-- lib/selection_dialog.dart | 11 ++++++----- pubspec.yaml | 2 +- 6 files changed, 26 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5058b66..db3d050 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,4 +24,8 @@ 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 +Now onChanged has a full CElement as argument and not only a string. (issue #4) + +## 0.2.1 + +Added some documentation \ No newline at end of file diff --git a/README.md b/README.md index 08b7d22..74612f9 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Pub](https://img.shields.io/badge/Pub-0.2.0-orange.svg)](https://pub.dartlang.org/packages/country_code_picker) +[![Pub](https://img.shields.io/badge/Pub-0.2.1-orange.svg)](https://pub.dartlang.org/packages/country_code_picker) # country_code_picker diff --git a/lib/celement.dart b/lib/celement.dart index c15b0e6..eca9bae 100644 --- a/lib/celement.dart +++ b/lib/celement.dart @@ -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"; } } diff --git a/lib/country_code_picker.dart b/lib/country_code_picker.dart index c63761b..fc16dec 100644 --- a/lib/country_code_picker.dart +++ b/lib/country_code_picker.dart @@ -55,8 +55,9 @@ 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(); super.initState(); diff --git a/lib/selection_dialog.dart b/lib/selection_dialog.dart index 968d49e..3227f8c 100644 --- a/lib/selection_dialog.dart +++ b/lib/selection_dialog.dart @@ -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 elements; + + /// elements passed as favorite final List favoriteElements; SelectionDialog(this.elements, this.favoriteElements); @@ -12,6 +15,7 @@ class SelectionDialog extends StatefulWidget { } class _SelectionDialogState extends State { + /// this is useful for filtering purpose List showedElements = []; @override @@ -56,10 +60,7 @@ class _SelectionDialogState extends State { 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(); }); } diff --git a/pubspec.yaml b/pubspec.yaml index f04b8f8..195e9b4 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.2.0 +version: 0.2.1 author: Salvatore-Giordano homepage: https://github.com/Salvatore-Giordano/CountryCodePicker