@@ -9,11 +9,11 @@ import 'package:saber/pages/editor/editor.dart';
99class SortNotes {
1010 SortNotes ._();
1111
12- static final Map < String , void Function (List <String >, bool )> _sortFunctions = {
13- t.home.sortNames.alphabetical : _sortNotesAlpha,
14- t.home.sortNames.lastModified : _sortNotesLastModified,
15- t.home.sortNames.sizeOnDisk : _sortNotesSize,
16- } ;
12+ static final List < void Function (List <String >, bool )> _sortFunctions = [
13+ _sortNotesAlpha,
14+ _sortNotesLastModified,
15+ _sortNotesSize,
16+ ] ;
1717 static final PlainPref <int > _sortFunctionIdx = Prefs .sortFunctionIdx;
1818 static final PlainPref <bool > _isIncreasingOrder = Prefs .isSortIncreasing;
1919
@@ -43,8 +43,7 @@ class SortNotes {
4343
4444 static void sortNotes (List <String > filePaths, {bool forced = false }) {
4545 if (_isNeeded || forced) {
46- _sortFunctions[_sortFunctions.keys.elementAt (sortFunctionIdx)]!
47- .call (filePaths, isIncreasingOrder);
46+ _sortFunctions[sortFunctionIdx].call (filePaths, isIncreasingOrder);
4847 _isNeeded = false ;
4948 }
5049 }
@@ -144,7 +143,12 @@ class _SortButtonDialog extends StatefulWidget {
144143class _SortButtonDialogState extends State <_SortButtonDialog > {
145144 @override
146145 Widget build (BuildContext context) {
147- final List <String > sortNames = SortNotes ._sortFunctions.keys.toList ();
146+ // Needs to match the order of _sortFunctions
147+ final List <String > sortNames = [
148+ t.home.sortNames.alphabetical,
149+ t.home.sortNames.lastModified,
150+ t.home.sortNames.sizeOnDisk,
151+ ];
148152
149153 return Align (
150154 alignment: Alignment .topRight,
0 commit comments