Merge pull request #25 from Afulton11/feature/styleable-search-field

Add custom search InputDecoration to SelectionDialog
This commit is contained in:
Salvatore Giordano
2019-04-12 09:54:22 +02:00
committed by GitHub
2 changed files with 16 additions and 2 deletions

View File

@@ -14,6 +14,8 @@ class CountryCodePicker extends StatefulWidget {
final TextStyle textStyle;
final EdgeInsetsGeometry padding;
final bool showCountryOnly;
final InputDecoration searchDecoration;
final TextStyle searchStyle;
final WidgetBuilder emptySearchBuilder;
/// shows the name of the country instead of the dialcode
@@ -33,6 +35,8 @@ class CountryCodePicker extends StatefulWidget {
this.textStyle,
this.padding = const EdgeInsets.all(0.0),
this.showCountryOnly = false,
this.searchDecoration = const InputDecoration(),
this.searchStyle,
this.emptySearchBuilder,
this.showOnlyCountryWhenClosed = false,
this.alignLeft = false,
@@ -132,6 +136,8 @@ class _CountryCodePickerState extends State<CountryCodePicker> {
favoriteElements,
showCountryOnly: widget.showCountryOnly,
emptySearchBuilder: widget.emptySearchBuilder,
searchDecoration: widget.searchDecoration,
searchStyle: widget.searchStyle,
),
).then((e) {
if (e != null) {

View File

@@ -5,6 +5,8 @@ import 'package:flutter/material.dart';
class SelectionDialog extends StatefulWidget {
final List<CountryCode> elements;
final bool showCountryOnly;
final InputDecoration searchDecoration;
final TextStyle searchStyle;
final WidgetBuilder emptySearchBuilder;
/// elements passed as favorite
@@ -14,7 +16,12 @@ class SelectionDialog extends StatefulWidget {
Key key,
this.showCountryOnly,
this.emptySearchBuilder,
}) : super(key: key);
InputDecoration searchDecoration = const InputDecoration(),
this.searchStyle,
}) :
assert(searchDecoration != null, 'searchDecoration must not be null!'),
this.searchDecoration = searchDecoration.copyWith(prefixIcon: Icon(Icons.search)),
super(key: key);
@override
State<StatefulWidget> createState() => _SelectionDialogState();
@@ -29,7 +36,8 @@ class _SelectionDialogState extends State<SelectionDialog> {
title: Column(
children: <Widget>[
TextField(
decoration: const InputDecoration(prefixIcon: Icon(Icons.search)),
style: widget.searchStyle,
decoration: widget.searchDecoration,
onChanged: _filterElements,
),
],