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 a 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 on the web, the title should change to reflect the current page’s features and to allow search engines (I haven’t confirmed this) to index content.

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

Put these codes within the 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 *


Scroll to Top

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