setPageTitle function

void setPageTitle(
  1. String title, {
  2. int? colorInt,
})

Sets the page title for web applications, which appears in the browser tab or task switcher.

title is the string to be displayed as the page title. colorInt is an optional integer representing the primary color for the application switcher.

Implementation

void setPageTitle(String title, {int? colorInt}) {
  // This function is only applicable for web platforms.
  if (kIsWeb) {
    SystemChrome.setApplicationSwitcherDescription(
      ApplicationSwitcherDescription(
        label: title,
        primaryColor:
            colorInt ?? 0xFF000000, // Default to black if no color is provided.
      ),
    );
  }
}