jonataslaw / jonataslaw/getx

getx Nested routing bug

Open
#2,003 1 comment 3 reactions 1 assignee Claimed by @jonataslaw View on GitHub
Dominant language
Dart
Stars
11.2k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

getx Nested routing bug
source code: https://github.com/liseipi/demo1.git

example:

```index.dart
class IndexPage extends GetView {
const IndexPage({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return Scaffold(
body: Navigator(
key: Get.nestedKey(1),
initialRoute: '/home',
onGenerateRoute: controller.onGenerateRoute,
),
bottomNavigationBar: Obx(
() => BottomNavigationBar(
items: const [
BottomNavigationBarItem(
icon: Icon(Icons.home),
label: 'Home',
),
BottomNavigationBarItem(
icon: Icon(Icons.account_circle),
label: 'My',
),
],
currentIndex: controller.currentIndex.value,
selectedItemColor: Colors.pink,
onTap: controller.changePage,
),
),
);
}
}
```

```home.dart
class HomePage extends GetView {
const HomePage({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return Navigator(
key: Get.nestedKey(2),
initialRoute: '/recommend',
onGenerateRoute: controller.onGenerateRoute,
);
}
}
```

**To Reproduce**
Steps to reproduce the behavior:
1. Click BottomNavigation change
2. show error

```
The following assertion was thrown while finalizing the widget tree:
Duplicate GlobalKey detected in widget tree.

The following GlobalKey was specified multiple times in the widget tree. This will lead to parts of the widget tree being truncated unexpectedly, because the second time a key is seen, the previous instance is moved to the new location. The key was:

```

**Minimal reproduce code**
My smallest source code address: https://github.com/liseipi/demo1.git

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.