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

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