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
|
## 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
|
# country_code_picker
|
||||||
|
|
||||||
|
|||||||
@@ -18,10 +18,14 @@ class CElement {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return defaultTargetPlatform == TargetPlatform.android ? "$flag $dialCode" : dialCode;
|
return defaultTargetPlatform == TargetPlatform.android
|
||||||
|
? "$flag $dialCode"
|
||||||
|
: dialCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
String toLongString() {
|
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:country_code_picker/selection_dialog.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
export 'celement.dart';
|
||||||
|
|
||||||
class CountryCodePicker extends StatefulWidget {
|
class CountryCodePicker extends StatefulWidget {
|
||||||
final Function(CElement) onChanged;
|
final Function(CElement) onChanged;
|
||||||
final String initialSelection;
|
final String initialSelection;
|
||||||
final List<String> favorite;
|
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
|
@override
|
||||||
State<StatefulWidget> createState() {
|
State<StatefulWidget> createState() {
|
||||||
@@ -36,9 +45,13 @@ class _CountryCodePickerState extends State<CountryCodePicker> {
|
|||||||
_CountryCodePickerState(this.elements);
|
_CountryCodePickerState(this.elements);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => new GestureDetector(
|
Widget build(BuildContext context) => new FlatButton(
|
||||||
child: new Text("${selectedItem.toString()}"),
|
child: new Text(
|
||||||
onTap: _showSelectionDialog,
|
"${selectedItem.toString()}",
|
||||||
|
style: widget.textStyle ?? Theme.of(context).textTheme.button,
|
||||||
|
),
|
||||||
|
padding: widget.padding,
|
||||||
|
onPressed: _showSelectionDialog,
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -60,7 +60,10 @@ class _SelectionDialogState extends State<SelectionDialog> {
|
|||||||
s = s.toUpperCase();
|
s = s.toUpperCase();
|
||||||
setState(() {
|
setState(() {
|
||||||
showedElements = widget.elements
|
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();
|
.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.1
|
version: 0.2.2
|
||||||
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