mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-12-12 19:17:58 +00:00
fix: flutter remove setState in initState (#8807)
Signed-off-by: dignow <linlong1265@gmail.com>
This commit is contained in:
@@ -78,6 +78,13 @@ class _PeerTabPageState extends State<PeerTabPage>
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_loadLocalOptions();
|
||||
});
|
||||
super.initState();
|
||||
}
|
||||
|
||||
Future<void> _loadLocalOptions() async {
|
||||
final uiType = bind.getLocalFlutterOption(k: kOptionPeerCardUiType);
|
||||
if (uiType != '') {
|
||||
peerCardUiType.value = int.parse(uiType) == 0
|
||||
@@ -88,7 +95,6 @@ class _PeerTabPageState extends State<PeerTabPage>
|
||||
}
|
||||
hideAbTagsPanel.value =
|
||||
bind.mainGetLocalOption(key: kOptionHideAbTagsPanel) == 'Y';
|
||||
super.initState();
|
||||
}
|
||||
|
||||
Future<void> handleTabSelection(int tabIndex) async {
|
||||
@@ -875,18 +881,22 @@ class _PeerSortDropdownState extends State<PeerSortDropdown> {
|
||||
@override
|
||||
void initState() {
|
||||
if (!PeerSortType.values.contains(peerSort.value)) {
|
||||
Future.delayed(Duration.zero, () {
|
||||
// do not change obx directly in initState, so do in future.
|
||||
peerSort.value = PeerSortType.remoteId;
|
||||
bind.setLocalFlutterOption(
|
||||
k: kOptionPeerSorting,
|
||||
v: peerSort.value,
|
||||
);
|
||||
// do not change obx directly in initState, so do in future.
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_loadLocalOptions();
|
||||
});
|
||||
}
|
||||
super.initState();
|
||||
}
|
||||
|
||||
Future<void> _loadLocalOptions() async {
|
||||
peerSort.value = PeerSortType.remoteId;
|
||||
bind.setLocalFlutterOption(
|
||||
k: kOptionPeerSorting,
|
||||
v: peerSort.value,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final style = TextStyle(
|
||||
|
||||
Reference in New Issue
Block a user