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

Add custom search InputDecoration to SelectionDialog
This commit is contained in:
Andrew Fulton
2019-04-01 22:14:22 -05:00
committed by GitHub
2 changed files with 9 additions and 2 deletions

View File

@@ -14,6 +14,7 @@ class CountryCodePicker extends StatefulWidget {
final TextStyle textStyle;
final EdgeInsetsGeometry padding;
final bool showCountryOnly;
final InputDecoration searchDecoration;
final WidgetBuilder emptySearchBuilder;
CountryCodePicker({
@@ -23,6 +24,7 @@ class CountryCodePicker extends StatefulWidget {
this.textStyle,
this.padding = const EdgeInsets.all(0.0),
this.showCountryOnly = false,
this.searchDecoration,
this.emptySearchBuilder,
});
@@ -115,6 +117,7 @@ class _CountryCodePickerState extends State<CountryCodePicker> {
favoriteElements,
showCountryOnly: widget.showCountryOnly,
emptySearchBuilder: widget.emptySearchBuilder,
searchDecoration: widget.searchDecoration,
),
).then((e) {
if (e != null) {

View File

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