@@ -14,8 +14,8 @@ final class Select<T> with TerminalTools implements Component<Future<T>> {
1414 final _completer = Completer <T >();
1515
1616 final Terminal _terminal;
17- SelectTheme _theme;
18- late int _displayCount;
17+ final SelectTheme _theme;
18+ late final int _displayCount;
1919
2020 int _currentIndex = 0 ;
2121 T ? _selectedOption;
@@ -69,18 +69,22 @@ final class Select<T> with TerminalTools implements Component<Future<T>> {
6969 _currentIndex = _currentIndex - 1 ;
7070 _render ();
7171 }
72- } else if (key.controlChar == ControlCharacter .arrowDown || key.char == 'j' ) {
72+ } else if (key.controlChar == ControlCharacter .arrowDown ||
73+ key.char == 'j' ) {
7374 if (_currentIndex < _filteredOptions.length - 1 ) {
7475 _currentIndex = _currentIndex + 1 ;
7576 _render ();
7677 }
77- } else if ([ControlCharacter .ctrlJ, ControlCharacter .ctrlM].contains (key.controlChar)) {
78+ } else if ([ControlCharacter .ctrlJ, ControlCharacter .ctrlM]
79+ .contains (key.controlChar)) {
7880 _onSubmit ();
7981 } else {
80- if (RegExp (r'^[\p{L}\p{N}\p{P}\s\x7F]*$' , unicode: true ).hasMatch (key.char)) {
82+ if (RegExp (r'^[\p{L}\p{N}\p{P}\s\x7F]*$' , unicode: true )
83+ .hasMatch (key.char)) {
8184 _currentIndex = 0 ;
8285
83- if (key.controlChar == ControlCharacter .backspace && _filter.isNotEmpty) {
86+ if (key.controlChar == ControlCharacter .backspace &&
87+ _filter.isNotEmpty) {
8488 _filter = _filter.substring (0 , _filter.length - 1 );
8589 } else if (key.controlChar != ControlCharacter .backspace) {
8690 _filter = _filter + key.char;
@@ -97,7 +101,9 @@ final class Select<T> with TerminalTools implements Component<Future<T>> {
97101 List <T > _filterOptions () {
98102 return _options.where ((item) {
99103 final value = _onDisplay? .call (item) ?? item.toString ();
100- return _options.isNotEmpty ? value.toLowerCase ().contains (_filter.toLowerCase ()) : true ;
104+ return _options.isNotEmpty
105+ ? value.toLowerCase ().contains (_filter.toLowerCase ())
106+ : true ;
101107 }).toList ();
102108 }
103109
@@ -112,7 +118,9 @@ final class Select<T> with TerminalTools implements Component<Future<T>> {
112118 Print (_theme.askPrefix),
113119 SetStyles .reset,
114120 Print (' $_message ' ),
115- ..._filter.isEmpty ? _theme.placeholderColorMessage : _theme.filterColorMessage,
121+ ..._filter.isEmpty
122+ ? _theme.placeholderColorMessage
123+ : _theme.filterColorMessage,
116124 _filter.isEmpty ? Print (_placeholder) : Print (_filter),
117125 SetStyles .reset,
118126 AsciiControl .lineFeed,
@@ -121,7 +129,9 @@ final class Select<T> with TerminalTools implements Component<Future<T>> {
121129 _filteredOptions.clear ();
122130 _filteredOptions.addAll (_filterOptions ());
123131
124- int start = _currentIndex - _displayCount >= 0 ? _currentIndex - _displayCount + 1 : 0 ;
132+ int start = _currentIndex - _displayCount >= 0
133+ ? _currentIndex - _displayCount + 1
134+ : 0 ;
125135
126136 for (final choice in _filteredOptions.skip (start).take (_displayCount)) {
127137 final isCurrent = _filteredOptions.indexOf (choice) == _currentIndex;
@@ -172,7 +182,8 @@ final class Select<T> with TerminalTools implements Component<Future<T>> {
172182 SetStyles .reset,
173183 Print (' $_message ' ),
174184 ..._theme.resultMessageColor,
175- Print (_onDisplay? .call (_selectedOption as T ) ?? _selectedOption.toString ()),
185+ Print (
186+ _onDisplay? .call (_selectedOption as T ) ?? _selectedOption.toString ()),
176187 SetStyles .reset,
177188 AsciiControl .lineFeed,
178189 ]);
0 commit comments