diff --git a/flutter/lib/common/widgets/peer_tab_page.dart b/flutter/lib/common/widgets/peer_tab_page.dart index 52bdc8cc6..2d36d9150 100644 --- a/flutter/lib/common/widgets/peer_tab_page.dart +++ b/flutter/lib/common/widgets/peer_tab_page.dart @@ -1,3 +1,4 @@ +import 'dart:math'; import 'dart:ui' as ui; import 'package:bot_toast/bot_toast.dart'; @@ -453,6 +454,13 @@ class _PeerSortDropdownState extends State { color: Theme.of(context).colorScheme.background, borderRadius: BorderRadius.circular(5), ); + + final translated_text = + PeerSortType.values.map((e) => translate(e)).toList(); + + final double max_width = + 50 + translated_text.map((e) => e.length).reduce(max) * 10; + return Container( padding: EdgeInsets.all(4.0), decoration: deco, @@ -471,12 +479,13 @@ class _PeerSortDropdownState extends State { Icons.sort, size: 18, ), + isExpanded: true, dropdownStyleData: DropdownStyleData( decoration: BoxDecoration( color: Theme.of(context).cardColor, borderRadius: BorderRadius.circular(10), ), - width: 160, + width: max_width, ), items: [ DropdownMenuItem( @@ -487,7 +496,7 @@ class _PeerSortDropdownState extends State { ), enabled: false, ), - ...PeerSortType.values + ...translated_text .map>( (String value) => DropdownMenuItem( value: value, @@ -500,7 +509,7 @@ class _PeerSortDropdownState extends State { size: 18, ).paddingOnly(right: 12), Text( - translate(value), + value, overflow: TextOverflow.ellipsis, ), ],