From bb7d3c75c860ef70e6ed4432c11e0b601fe67464 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Sat, 4 Apr 2020 16:15:25 +0200 Subject: [PATCH] refs #59: add dialog size --- lib/country_code_picker.dart | 5 +++++ lib/selection_dialog.dart | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/country_code_picker.dart b/lib/country_code_picker.dart index 7e491da..6088deb 100644 --- a/lib/country_code_picker.dart +++ b/lib/country_code_picker.dart @@ -22,6 +22,9 @@ class CountryCodePicker extends StatefulWidget { final bool enabled; final TextOverflow textOverflow; + /// the size of the selection dialog + final Size dialogSize; + /// used to customize the country list final List customList; @@ -74,6 +77,7 @@ class CountryCodePicker extends StatefulWidget { this.textOverflow = TextOverflow.ellipsis, this.comparator, this.customList, + this.dialogSize, }); @override @@ -213,6 +217,7 @@ class _CountryCodePickerState extends State { searchStyle: widget.searchStyle, showFlag: widget.showFlag || (widget.showFlagDialog == true), flagWidth: widget.flagWidth, + size: widget.dialogSize, ), ).then((e) { if (e != null) { diff --git a/lib/selection_dialog.dart b/lib/selection_dialog.dart index eb010c4..ae6beb2 100644 --- a/lib/selection_dialog.dart +++ b/lib/selection_dialog.dart @@ -10,6 +10,7 @@ class SelectionDialog extends StatefulWidget { final WidgetBuilder emptySearchBuilder; final bool showFlag; final double flagWidth; + final Size size; /// elements passed as favorite final List favoriteElements; @@ -24,6 +25,7 @@ class SelectionDialog extends StatefulWidget { this.searchStyle, this.showFlag, this.flagWidth = 32, + this.size, }) : assert(searchDecoration != null, 'searchDecoration must not be null!'), this.searchDecoration = searchDecoration.copyWith(prefixIcon: Icon(Icons.search)), @@ -64,8 +66,9 @@ class _SelectionDialogState extends State { ), children: [ Container( - width: MediaQuery.of(context).size.width, - height: MediaQuery.of(context).size.height * 0.7, + width: widget.size?.width ?? MediaQuery.of(context).size.width, + height: + widget.size?.height ?? MediaQuery.of(context).size.height * 0.7, child: ListView( children: [ widget.favoriteElements.isEmpty