mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-07-28 20:00:16 +02:00
'Fix' for GlobalKey error #254
This commit is contained in:
@@ -63,21 +63,29 @@ class _HomePageState extends State<HomePage> {
|
|||||||
.map((e) =>
|
.map((e) =>
|
||||||
NavigationDestination(icon: Icon(e.icon), label: e.title))
|
NavigationDestination(icon: Icon(e.icon), label: e.title))
|
||||||
.toList(),
|
.toList(),
|
||||||
onDestinationSelected: (int index) {
|
onDestinationSelected: (int index) async {
|
||||||
HapticFeedback.selectionClick();
|
HapticFeedback.selectionClick();
|
||||||
setState(() {
|
if (index == 0) {
|
||||||
if (index == 0) {
|
while ((pages[0].widget.key as GlobalKey<AppsPageState>)
|
||||||
|
.currentState !=
|
||||||
|
null) {
|
||||||
|
// Avoid duplicate GlobalKey error
|
||||||
|
await Future.delayed(const Duration(milliseconds: 200));
|
||||||
|
}
|
||||||
|
setState(() {
|
||||||
selectedIndexHistory.clear();
|
selectedIndexHistory.clear();
|
||||||
} else if (selectedIndexHistory.isEmpty ||
|
});
|
||||||
(selectedIndexHistory.isNotEmpty &&
|
} else if (selectedIndexHistory.isEmpty ||
|
||||||
selectedIndexHistory.last != index)) {
|
(selectedIndexHistory.isNotEmpty &&
|
||||||
|
selectedIndexHistory.last != index)) {
|
||||||
|
setState(() {
|
||||||
int existingInd = selectedIndexHistory.indexOf(index);
|
int existingInd = selectedIndexHistory.indexOf(index);
|
||||||
if (existingInd >= 0) {
|
if (existingInd >= 0) {
|
||||||
selectedIndexHistory.removeAt(existingInd);
|
selectedIndexHistory.removeAt(existingInd);
|
||||||
}
|
}
|
||||||
selectedIndexHistory.add(index);
|
selectedIndexHistory.add(index);
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
},
|
},
|
||||||
selectedIndex:
|
selectedIndex:
|
||||||
selectedIndexHistory.isEmpty ? 0 : selectedIndexHistory.last,
|
selectedIndexHistory.isEmpty ? 0 : selectedIndexHistory.last,
|
||||||
|
Reference in New Issue
Block a user