Add custom search InputDecoration to SelectionDialog
This commit is contained in:
@@ -14,6 +14,7 @@ class CountryCodePicker extends StatefulWidget {
|
||||
final TextStyle textStyle;
|
||||
final EdgeInsetsGeometry padding;
|
||||
final bool showCountryOnly;
|
||||
final InputDecoration searchDecoration;
|
||||
|
||||
CountryCodePicker({
|
||||
this.onChanged,
|
||||
@@ -22,6 +23,7 @@ class CountryCodePicker extends StatefulWidget {
|
||||
this.textStyle,
|
||||
this.padding = const EdgeInsets.all(0.0),
|
||||
this.showCountryOnly = false,
|
||||
this.searchDecoration,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -108,7 +110,8 @@ class _CountryCodePickerState extends State<CountryCodePicker> {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (_) => new SelectionDialog(elements, favoriteElements,
|
||||
showCountryOnly: widget.showCountryOnly),
|
||||
showCountryOnly: widget.showCountryOnly,
|
||||
searchDecoration: widget.searchDecoration,),
|
||||
).then((e) {
|
||||
if (e != null) {
|
||||
setState(() {
|
||||
|
||||
@@ -5,11 +5,15 @@ import 'package:flutter/material.dart';
|
||||
class SelectionDialog extends StatefulWidget {
|
||||
final List<CountryCode> elements;
|
||||
final bool showCountryOnly;
|
||||
final InputDecoration searchDecoration;
|
||||
|
||||
/// elements passed as favorite
|
||||
final List<CountryCode> favoriteElements;
|
||||
|
||||
SelectionDialog(this.elements, this.favoriteElements, {this.showCountryOnly});
|
||||
SelectionDialog(this.elements, this.favoriteElements, {
|
||||
this.showCountryOnly,
|
||||
InputDecoration searchDecoration = const InputDecoration(),
|
||||
}) : this.searchDecoration = searchDecoration.copyWith(prefixIcon: Icon(Icons.search));
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => new _SelectionDialogState();
|
||||
@@ -24,7 +28,7 @@ class _SelectionDialogState extends State<SelectionDialog> {
|
||||
title: new Column(
|
||||
children: <Widget>[
|
||||
new TextField(
|
||||
decoration: new InputDecoration(prefixIcon: new Icon(Icons.search)),
|
||||
decoration: widget.searchDecoration,
|
||||
onChanged: _filterElements,
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user