Flutter Navigator 2.0

Nov 8 2022 · Dart 2.17.3, Flutter 3.0.2, Android Studio 2020.3

Part 4: Deep Links & Web Urls

20. Create a Navigation State Object

Episode complete

Play next episode

Next
About this episode
Leave a rating/review
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 19. Setup Deep Links Next episode: 21. Create a Route Information Parser

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

Episode - 20 Create a Navigation State Object

Let us start by creating a Navigation State Object that will hold the state of the navigation. Currently we have an App State Manager that manages the state of the app, but nothing to manage the state of the navigation.

location = Uri.decodeFull(location ?? ''); 
final uri = Uri.parse(location); 
final params = uri.queryParameters;
final itemId = params[AppLink.idParam]; 
final link AppLink(
	location: uri.path,
	itemId: itemId
	);

return link;

case loginPath: 
	return loginPath;
case itemPath:
var loc = '$itemPath?';
	String addKeyValuePair({required String key, String? value}){
		value == null ? '${key}=$value';
	}
	loc += addKeyValuePair(key: idParam, value: itemId);
	return Uri.encodeFull(loc);