I was able to navigate to other pages by changing the url of my flutter web hosted on netlify(manually deployed) by typing the url in search bar as shown below:-
So if i change /home to /about then it leads me perfectly to about page. But to remove this '#' from my url i added the following code in my main.dart My Code:-
import 'package:url_strategy/url_strategy.dart';
void main()async {
await Firebase.initializeApp();
setPathUrlStrategy();//this removes the '#' from my url
FluroRouting.setupRouter();
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'My Website',
theme: ThemeData(
primarySwatch: Colors.blue,
),
initialRoute: '/home',
onGenerateRoute: FluroRouting.router.generator,
);
}
}
and code for routing is:-
class FluroRouting {
static final router = FluroRouter();
static Handler _aboutUsHandler = Handler(
handlerFunc: (BuildContext context, Map<String, dynamic> params) =>
AboutUs());
static Handler _homeHandler = Handler(
handlerFunc: (BuildContext context, Map<String, dynamic> params) =>
HomePage());
static void setupRouter() {
router.define('/home', handler: _homeHandler,);
router.define('/about', handler: _aboutUsHandler,);
}
static void navigateToPage({String routeName,BuildContext context}) {
router.navigateTo(context, routeName, transition: TransitionType.none);
}
static void pushAndClearStackToPage({String routeName,BuildContext context}) {
router.navigateTo(context, routeName, clearStack: true,transition: TransitionType.none);
}
}
After doing so the '#' was successfully removed but when i change /home to /about then it shows page not found error.