Merge pull request #25 from Afulton11/feature/styleable-search-field
Add custom search InputDecoration to SelectionDialog
This commit is contained in:
@@ -14,6 +14,8 @@ class CountryCodePicker extends StatefulWidget {
|
|||||||
final TextStyle textStyle;
|
final TextStyle textStyle;
|
||||||
final EdgeInsetsGeometry padding;
|
final EdgeInsetsGeometry padding;
|
||||||
final bool showCountryOnly;
|
final bool showCountryOnly;
|
||||||
|
final InputDecoration searchDecoration;
|
||||||
|
final TextStyle searchStyle;
|
||||||
final WidgetBuilder emptySearchBuilder;
|
final WidgetBuilder emptySearchBuilder;
|
||||||
|
|
||||||
/// shows the name of the country instead of the dialcode
|
/// shows the name of the country instead of the dialcode
|
||||||
@@ -33,6 +35,8 @@ class CountryCodePicker extends StatefulWidget {
|
|||||||
this.textStyle,
|
this.textStyle,
|
||||||
this.padding = const EdgeInsets.all(0.0),
|
this.padding = const EdgeInsets.all(0.0),
|
||||||
this.showCountryOnly = false,
|
this.showCountryOnly = false,
|
||||||
|
this.searchDecoration = const InputDecoration(),
|
||||||
|
this.searchStyle,
|
||||||
this.emptySearchBuilder,
|
this.emptySearchBuilder,
|
||||||
this.showOnlyCountryWhenClosed = false,
|
this.showOnlyCountryWhenClosed = false,
|
||||||
this.alignLeft = false,
|
this.alignLeft = false,
|
||||||
@@ -132,6 +136,8 @@ class _CountryCodePickerState extends State<CountryCodePicker> {
|
|||||||
favoriteElements,
|
favoriteElements,
|
||||||
showCountryOnly: widget.showCountryOnly,
|
showCountryOnly: widget.showCountryOnly,
|
||||||
emptySearchBuilder: widget.emptySearchBuilder,
|
emptySearchBuilder: widget.emptySearchBuilder,
|
||||||
|
searchDecoration: widget.searchDecoration,
|
||||||
|
searchStyle: widget.searchStyle,
|
||||||
),
|
),
|
||||||
).then((e) {
|
).then((e) {
|
||||||
if (e != null) {
|
if (e != null) {
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import 'package:flutter/material.dart';
|
|||||||
class SelectionDialog extends StatefulWidget {
|
class SelectionDialog extends StatefulWidget {
|
||||||
final List<CountryCode> elements;
|
final List<CountryCode> elements;
|
||||||
final bool showCountryOnly;
|
final bool showCountryOnly;
|
||||||
|
final InputDecoration searchDecoration;
|
||||||
|
final TextStyle searchStyle;
|
||||||
final WidgetBuilder emptySearchBuilder;
|
final WidgetBuilder emptySearchBuilder;
|
||||||
|
|
||||||
/// elements passed as favorite
|
/// elements passed as favorite
|
||||||
@@ -14,7 +16,12 @@ class SelectionDialog extends StatefulWidget {
|
|||||||
Key key,
|
Key key,
|
||||||
this.showCountryOnly,
|
this.showCountryOnly,
|
||||||
this.emptySearchBuilder,
|
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
|
@override
|
||||||
State<StatefulWidget> createState() => _SelectionDialogState();
|
State<StatefulWidget> createState() => _SelectionDialogState();
|
||||||
@@ -29,7 +36,8 @@ class _SelectionDialogState extends State<SelectionDialog> {
|
|||||||
title: Column(
|
title: Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
TextField(
|
TextField(
|
||||||
decoration: const InputDecoration(prefixIcon: Icon(Icons.search)),
|
style: widget.searchStyle,
|
||||||
|
decoration: widget.searchDecoration,
|
||||||
onChanged: _filterElements,
|
onChanged: _filterElements,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user