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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With