Skip to content

Commit

Permalink
Do not refresh whole widget tree when change autostart Checkbox widge…
Browse files Browse the repository at this point in the history
…t state
  • Loading branch information
Muska-Ami committed Sep 10, 2024
1 parent 554bc12 commit 2707a25
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions nyalcf_gui/nyalcf_ui/lib/controllers/proxies_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,29 @@ class ProxiesController extends GetxController {
Row(children: <Widget>[
Container(
margin: const EdgeInsets.only(left: 5.0),
child: Checkbox(
value: _getIfAutostart(element.id),
onChanged: (value) async {
_changeAutostart(element.id, value);
},
),
child: Builder(builder: (BuildContext context) {
ValueNotifier<bool> autostartNotifier =
ValueNotifier(_getIfAutostart(element.id));
return ValueListenableBuilder<bool>(
valueListenable: autostartNotifier,
builder: (context, isAutostart, child) {
return Checkbox(
value: isAutostart,
onChanged: (value) async {
_changeAutostart(element.id, value);
autostartNotifier.value =
value ?? false; // 更新通知器的值
},
);
},
);
}),
// Checkbox(
// value: _getIfAutostart(element.id),
// onChanged: (value) async {
// _changeAutostart(element.id, value);
// },
// ),
),
const Text('跟随程序启动'),
]),
Expand Down Expand Up @@ -174,7 +191,7 @@ class ProxiesController extends GetxController {
aps.save();
Logger.debug(_getIfAutostart(proxyId));
}
load(_uCtr.user, _uCtr.token);
// load(_uCtr.user, _uCtr.token);
}

/// 获取速度状态
Expand Down

0 comments on commit 2707a25

Please sign in to comment.