Add textStyle and padding as widget parameters

This commit is contained in:
Salvatore Giordano
2018-05-05 11:33:03 +02:00
parent 1614174f13
commit 2505585404
6 changed files with 34 additions and 10 deletions

View File

@@ -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

View File

@@ -1,4 +1,4 @@
[![Pub](https://img.shields.io/badge/Pub-0.2.1-orange.svg)](https://pub.dartlang.org/packages/country_code_picker)
[![Pub](https://img.shields.io/badge/Pub-0.2.2-orange.svg)](https://pub.dartlang.org/packages/country_code_picker)
# country_code_picker

View File

@@ -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";
}
}

View File

@@ -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

View File

@@ -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();
});
}

View File

@@ -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