diff --git a/flutter/lib/common/widgets/peer_tab_page.dart b/flutter/lib/common/widgets/peer_tab_page.dart index e3bb3a5be..869bd5fd9 100644 --- a/flutter/lib/common/widgets/peer_tab_page.dart +++ b/flutter/lib/common/widgets/peer_tab_page.dart @@ -435,7 +435,17 @@ class PeerSortDropdown extends StatefulWidget { } class _PeerSortDropdownState extends State { - String _sortType = peerSort.value; + @override + void initState() { + if (!PeerSortType.values.contains(peerSort.value)) { + peerSort.value = PeerSortType.remoteId; + bind.setLocalFlutterConfig( + k: "peer-sorting", + v: peerSort.value, + ); + } + super.initState(); + } @override Widget build(BuildContext context) { @@ -448,17 +458,13 @@ class _PeerSortDropdownState extends State { decoration: deco, child: DropdownButtonHideUnderline( child: DropdownButton2( - value: PeerSortType.values.contains(_sortType) - ? _sortType - : PeerSortType.remoteId, onChanged: (v) async { if (v != null) { - setState(() => _sortType = v); + setState(() => peerSort.value = v); await bind.setLocalFlutterConfig( k: "peer-sorting", - v: _sortType, + v: peerSort.value, ); - peerSort.value = _sortType; } }, customButton: Icon( @@ -488,7 +494,7 @@ class _PeerSortDropdownState extends State { child: Row( children: [ Icon( - value == _sortType + value == peerSort.value ? Icons.radio_button_checked_rounded : Icons.radio_button_off_rounded, size: 18,