getValue method

String getValue(
  1. String segment
)

Get value from URL following the provided segment.

for example,

if browser URI is pointing to: https://domain.com/profile/123/posts

Navigator.of(context).getValue('profile'); //-> 123

Please note that calling getValue on a Navigator who's context is enclosed on posts pages can only access values past its registration path.

for example, if a Navigator is registered posts page it can only access parts of URI after posts pages.

In domain.com/profile/123/posts/456/edit/789 allowed part is /posts/456/edit/789

Navigator.of(context).getValue('posts') // -> '456'
Navigator.of(context).getValue('edit') // -> '789'

// accessing protected values:
Navigator.of(context).getValue('profile') // -> '', empty,
// because current navigator is registered on posts page

Implementation

String getValue(String segment) {
  if (_isDisposed) {
    throw Exception('Cannot call getValue() after state is disposed off.');
  }

  return _renderElement!.getValue(segment);
}