Skip to content

Commit

Permalink
fix: _children has not been initialized exception
Browse files Browse the repository at this point in the history
  • Loading branch information
foxsofter committed Mar 27, 2024
1 parent 1d06a11 commit 63c1a0e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 4.9.2

- fix: _children has not been initialized exception

## 4.9.1

- fix: NavigatorRoute type cast error in NavigatorObserverManager.didRemove
Expand Down
4 changes: 2 additions & 2 deletions lib/src/navigator/navigator_page_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ class NavigatorPageView extends StatefulWidget {

final bool padEnds;

late List<Widget> _children;
List<Widget>? _children;

List<Widget> get children => _children;
List<Widget>? get children => _children;

@override
State<NavigatorPageView> createState() => _NavigatorPageViewState();
Expand Down
7 changes: 5 additions & 2 deletions lib/src/navigator/navigator_tab_bar_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,11 @@ class _NavigatorTabBarViewState extends State<NavigatorTabBarView> {
}

void _updateChildren() {
if (pv != null) {
_childrenWithKey = KeyedSubtree.ensureUniqueKeysForList(pv!.children);
if (pv != null && pv?.children != null) {
_childrenWithKey = KeyedSubtree.ensureUniqueKeysForList(pv!.children!);
} else {
// 尽可能早的初始化
Future.delayed(const Duration(milliseconds: 10), _updateChildren);
}
}

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_thrio
description: Thrio makes it easy and fast to add flutter to existing mobile applications, and provide a simple and consistent navigator APIs.
version: 4.9.1
version: 4.9.2
homepage: https://github.com/flutter-thrio/flutter_thrio

environment:
Expand Down

0 comments on commit 63c1a0e

Please sign in to comment.