refs #63: add hideSearch property
This commit is contained in:
@@ -52,6 +52,7 @@ class _MyAppState extends State<MyApp> {
|
||||
child: CountryCodePicker(
|
||||
onChanged: print,
|
||||
initialSelection: 'TF',
|
||||
hideSearch: true,
|
||||
showCountryOnly: true,
|
||||
showOnlyCountryWhenClosed: true,
|
||||
alignLeft: true,
|
||||
|
||||
@@ -51,6 +51,9 @@ class CountryCodePicker extends StatefulWidget {
|
||||
/// Use this property to change the order of the options
|
||||
final Comparator<CountryCode> comparator;
|
||||
|
||||
/// Set to true if you want to hide the search part
|
||||
final bool hideSearch;
|
||||
|
||||
CountryCodePicker({
|
||||
this.onChanged,
|
||||
this.onInit,
|
||||
@@ -73,6 +76,7 @@ class CountryCodePicker extends StatefulWidget {
|
||||
this.textOverflow = TextOverflow.ellipsis,
|
||||
this.comparator,
|
||||
this.countryFilter,
|
||||
this.hideSearch = false,
|
||||
this.dialogSize,
|
||||
Key key,
|
||||
}) : super(key: key);
|
||||
@@ -181,6 +185,7 @@ class CountryCodePickerState extends State<CountryCodePicker> {
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (widget.initialSelection != null) {
|
||||
selectedItem = elements.firstWhere(
|
||||
(e) =>
|
||||
@@ -198,7 +203,6 @@ class CountryCodePickerState extends State<CountryCodePicker> {
|
||||
orElse: () => null) !=
|
||||
null)
|
||||
.toList();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
void showCountryCodePickerDialog() {
|
||||
@@ -214,6 +218,7 @@ class CountryCodePickerState extends State<CountryCodePicker> {
|
||||
showFlag: widget.showFlag || (widget.showFlagDialog == true),
|
||||
flagWidth: widget.flagWidth,
|
||||
size: widget.dialogSize,
|
||||
hideSearch: widget.hideSearch,
|
||||
),
|
||||
).then((e) {
|
||||
if (e != null) {
|
||||
|
||||
@@ -11,6 +11,7 @@ class SelectionDialog extends StatefulWidget {
|
||||
final bool showFlag;
|
||||
final double flagWidth;
|
||||
final Size size;
|
||||
final bool hideSearch;
|
||||
|
||||
/// elements passed as favorite
|
||||
final List<CountryCode> favoriteElements;
|
||||
@@ -26,6 +27,7 @@ class SelectionDialog extends StatefulWidget {
|
||||
this.showFlag,
|
||||
this.flagWidth = 32,
|
||||
this.size,
|
||||
this.hideSearch = false,
|
||||
}) : assert(searchDecoration != null, 'searchDecoration must not be null!'),
|
||||
this.searchDecoration =
|
||||
searchDecoration.copyWith(prefixIcon: Icon(Icons.search)),
|
||||
@@ -54,14 +56,15 @@ class _SelectionDialogState extends State<SelectionDialog> {
|
||||
),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
child: TextField(
|
||||
style: widget.searchStyle,
|
||||
decoration: widget.searchDecoration,
|
||||
onChanged: _filterElements,
|
||||
if (!widget.hideSearch)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
child: TextField(
|
||||
style: widget.searchStyle,
|
||||
decoration: widget.searchDecoration,
|
||||
onChanged: _filterElements,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
children: [
|
||||
|
||||
Reference in New Issue
Block a user