diff --git a/packages/go_router/CHANGELOG.md b/packages/go_router/CHANGELOG.md index 0e90fec1fa2..13cc0b746bc 100644 --- a/packages/go_router/CHANGELOG.md +++ b/packages/go_router/CHANGELOG.md @@ -1,3 +1,7 @@ +## 14.7.1 + +- Fixes return type of current state getter on `GoRouter` and `GoRouterDelegate` to be non-nullable. + ## 14.7.0 - Adds fragment support to GoRouter, enabling direct specification and automatic handling of fragments in routes. @@ -11,7 +15,6 @@ - Updates minimum supported SDK version to Flutter 3.22/Dart 3.4. - Updates readme. - ## 14.6.2 - Replaces deprecated collection method usage. diff --git a/packages/go_router/lib/src/delegate.dart b/packages/go_router/lib/src/delegate.dart index 56326e4faf7..3b90297be28 100644 --- a/packages/go_router/lib/src/delegate.dart +++ b/packages/go_router/lib/src/delegate.dart @@ -182,7 +182,7 @@ class GoRouterDelegate extends RouterDelegate /// The top [GoRouterState], the state of the route that was /// last used in either [GoRouter.go] or [GoRouter.push]. - GoRouterState? get state => currentConfiguration.last + GoRouterState get state => currentConfiguration.last .buildState(_configuration, currentConfiguration); /// For use by the Router architecture as part of the RouterDelegate. diff --git a/packages/go_router/lib/src/router.dart b/packages/go_router/lib/src/router.dart index 1070c42b047..6dfef3166a6 100644 --- a/packages/go_router/lib/src/router.dart +++ b/packages/go_router/lib/src/router.dart @@ -261,7 +261,7 @@ class GoRouter implements RouterConfig { /// Accessing this property via GoRouter.of(context).state will not /// cause rebuild if the state has changed, consider using /// GoRouterState.of(context) instead. - GoRouterState? get state => routerDelegate.state; + GoRouterState get state => routerDelegate.state; /// Whether the imperative API affects browser URL bar. /// diff --git a/packages/go_router/pubspec.yaml b/packages/go_router/pubspec.yaml index 5370fc7cac3..c020fd4ae31 100644 --- a/packages/go_router/pubspec.yaml +++ b/packages/go_router/pubspec.yaml @@ -1,8 +1,7 @@ name: go_router description: A declarative router for Flutter based on Navigation 2 supporting deep linking, data-driven routes and more -version: 14.7.0 - +version: 14.7.1 repository: https://github.com/flutter/packages/tree/main/packages/go_router issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+go_router%22 diff --git a/packages/go_router/test/go_router_test.dart b/packages/go_router/test/go_router_test.dart index 2e92c560a67..d98f10711c5 100644 --- a/packages/go_router/test/go_router_test.dart +++ b/packages/go_router/test/go_router_test.dart @@ -6030,39 +6030,39 @@ void main() { await tester.pumpAndSettle(); GoRouterState? state = router.state; - expect(state?.name, 'home'); - expect(state?.fullPath, '/'); + expect(state.name, 'home'); + expect(state.fullPath, '/'); router.go('/books'); await tester.pumpAndSettle(); state = router.state; - expect(state?.name, 'books'); - expect(state?.fullPath, '/books'); + expect(state.name, 'books'); + expect(state.fullPath, '/books'); router.push('/boats'); await tester.pumpAndSettle(); state = router.state; - expect(state?.name, 'boats'); - expect(state?.fullPath, '/boats'); + expect(state.name, 'boats'); + expect(state.fullPath, '/boats'); router.pop(); await tester.pumpAndSettle(); state = router.state; - expect(state?.name, 'books'); - expect(state?.fullPath, '/books'); + expect(state.name, 'books'); + expect(state.fullPath, '/books'); router.go('/tulips'); await tester.pumpAndSettle(); state = router.state; - expect(state?.name, 'tulips'); - expect(state?.fullPath, '/tulips'); + expect(state.name, 'tulips'); + expect(state.fullPath, '/tulips'); router.go('/books'); router.push('/tulips'); await tester.pumpAndSettle(); state = router.state; - expect(state?.name, 'tulips'); - expect(state?.fullPath, '/tulips'); + expect(state.name, 'tulips'); + expect(state.fullPath, '/tulips'); }); testWidgets('should allow route paths without leading /',