How to Dynamically Change Page Title in Flutter Web

When building an app you can set its title by using MaterialApp’s title property.

MaterialApp(
  title: 'App Title',
  home: MyHomePage(),
)

Using title means you won’t be able to change it without rebuilding the entire tree. It is fine for an app. But when it is a web, the title should change to reflect the current page’s feature and for search engine (I haven’t confirmed this).

We have another solution.SystemChrome.setApplicationSwitcherDescription in package:flutter/services.dart will solve this perfectly.

Put these codes within build method of a screen

SystemChrome.setApplicationSwitcherDescription(ApplicationSwitcherDescription(
      label: 'My current page title',
      primaryColor: Theme.of(context).primaryColor.value,
    ));

Leave a Comment

Your email address will not be published. Required fields are marked *

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close