Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the title of tab page in flutter web

I'm building a Flutter web project and I need to be able to change the title of the tab when I navigate to another page. I have tried the ongenerateRoute property but it isn't working. Here's how I did it.

import 'package:./routes.dart';
import 'package:flutter/material.dart';

String? routePath;

String getTabTitle(BuildContext context) {

  if (routePath == loginRoute) {
    return 'Login';
  } else if (routePath == dashboardRoute) {
    return 'Dashboard';
  } else if (routePath == overviewRoute) {
    return 'Overview';
  } else if (routePath == settingsRoute) {
    return 'Settings';
  } else {
    return 'Admin | Borku Africa';
  }
}

It seems the ongenerateRoute property only works for localizations. Please any way to work it around would be appreciated. Thanks.

like image 568
Kings Samuel Avatar asked Nov 29 '25 20:11

Kings Samuel


1 Answers

Flutter provide Title widget that can be used to change the title.

return Title(
  title: "Home Page",
  color: Colors.white,
  child: Scaffold(

More about Title.

like image 169
Yeasin Sheikh Avatar answered Dec 02 '25 12:12

Yeasin Sheikh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!