feat: 优化警告

This commit is contained in:
chaos-zhu
2026-05-24 23:25:42 +08:00
parent 236418b662
commit 20334fb549
4 changed files with 13 additions and 60 deletions
@@ -508,7 +508,7 @@ class _CardSection extends StatelessWidget {
),
),
),
if (trailing != null) trailing!,
?trailing,
],
),
if (children.isNotEmpty) const SizedBox(height: 14),
@@ -1096,55 +1096,6 @@ class _ProxyField extends StatelessWidget {
}
}
class _DropdownField<T> extends StatelessWidget {
const _DropdownField({
required this.label,
required this.value,
required this.items,
required this.onChanged,
this.validator,
this.icon,
this.enabled = true,
this.emptyText,
this.selectedItemBuilder,
});
final String label;
final T? value;
final List<DropdownMenuItem<T>> items;
final ValueChanged<T?> onChanged;
final String? Function(T?)? validator;
final IconData? icon;
final bool enabled;
final String? emptyText;
final DropdownButtonBuilder? selectedItemBuilder;
@override
Widget build(BuildContext context) {
return _LabeledBlock(
label: label,
child: DropdownButtonFormField<T>(
initialValue: value,
isExpanded: true,
items: items,
onChanged: enabled ? onChanged : null,
validator: validator,
hint: emptyText == null
? null
: Text(
emptyText!,
overflow: TextOverflow.ellipsis,
style: const TextStyle(color: _FormColors.label),
),
selectedItemBuilder: selectedItemBuilder,
icon: Icon(icon ?? Icons.keyboard_arrow_down, color: _FormColors.label),
style: const TextStyle(color: _FormColors.text, fontSize: 15),
decoration: _fieldDecoration(),
),
);
}
}
class _PickerField extends StatelessWidget {
const _PickerField({
required this.label,
+11 -9
View File
@@ -44,6 +44,16 @@ class _ServersTabState extends ConsumerState<ServersTab> {
super.dispose();
}
void toggleServerExpanded(String id) {
setState(() {
if (_expandedServerIds.contains(id)) {
_expandedServerIds.remove(id);
} else {
_expandedServerIds.add(id);
}
});
}
Future<void> _refresh() async {
await refreshServerSharedData(ref);
}
@@ -782,15 +792,7 @@ class _ServerCard extends StatelessWidget {
? Icons.keyboard_arrow_up
: Icons.keyboard_arrow_down,
highlighted: expanded,
onTap: () {
state.setState(() {
if (expanded) {
state._expandedServerIds.remove(server.id);
} else {
state._expandedServerIds.add(server.id);
}
});
},
onTap: () => state.toggleServerExpanded(server.id),
),
],
),
-1
View File
@@ -1,4 +1,3 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'strings_en.dart';
@@ -22,6 +22,7 @@ class _FakeRepository implements ServerRepository {
this.hosts = const [],
this.groups = const [],
this.fetchError,
// ignore: unused_element_parameter
this.groupFetchError,
SshConnectionConfig? config,
this.sshError,