Add textStyle and padding as widget parameters
This commit is contained in:
@@ -28,4 +28,8 @@ Now onChanged has a full CElement as argument and not only a string. (issue #4)
|
||||
|
||||
## 0.2.1
|
||||
|
||||
Added some documentation
|
||||
Added some documentation
|
||||
|
||||
## 0.2.2
|
||||
|
||||
Added textStyle and padding as widget parameters
|
||||
@@ -1,4 +1,4 @@
|
||||
[](https://pub.dartlang.org/packages/country_code_picker)
|
||||
[](https://pub.dartlang.org/packages/country_code_picker)
|
||||
|
||||
# country_code_picker
|
||||
|
||||
|
||||
@@ -18,10 +18,14 @@ class CElement {
|
||||
|
||||
@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";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,12 +5,21 @@ import 'package:country_code_picker/country_codes.dart';
|
||||
import 'package:country_code_picker/selection_dialog.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
export 'celement.dart';
|
||||
|
||||
class CountryCodePicker extends StatefulWidget {
|
||||
final Function(CElement) onChanged;
|
||||
final String initialSelection;
|
||||
final List<String> favorite;
|
||||
final TextStyle textStyle;
|
||||
final EdgeInsetsGeometry padding;
|
||||
|
||||
CountryCodePicker({this.onChanged, this.initialSelection, this.favorite});
|
||||
CountryCodePicker(
|
||||
{this.onChanged,
|
||||
this.initialSelection,
|
||||
this.favorite,
|
||||
this.textStyle,
|
||||
this.padding});
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
@@ -36,9 +45,13 @@ class _CountryCodePickerState extends State<CountryCodePicker> {
|
||||
_CountryCodePickerState(this.elements);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => new GestureDetector(
|
||||
child: new Text("${selectedItem.toString()}"),
|
||||
onTap: _showSelectionDialog,
|
||||
Widget build(BuildContext context) => new FlatButton(
|
||||
child: new Text(
|
||||
"${selectedItem.toString()}",
|
||||
style: widget.textStyle ?? Theme.of(context).textTheme.button,
|
||||
),
|
||||
padding: widget.padding,
|
||||
onPressed: _showSelectionDialog,
|
||||
);
|
||||
|
||||
@override
|
||||
|
||||
@@ -60,7 +60,10 @@ 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();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
name: country_code_picker
|
||||
description: A flutter package for showing a country code selector.
|
||||
version: 0.2.1
|
||||
version: 0.2.2
|
||||
author: Salvatore-Giordano <salvatoregiordanoo@gmail.com>
|
||||
homepage: https://github.com/Salvatore-Giordano/CountryCodePicker
|
||||
|
||||
|
||||
Reference in New Issue
Block a user