Closed
Description
Steps to reproduce
The GoRouter class has a requestFocus
property that should be passed all the way down to the Navigator constructor. Currently this is not used, so the following behaviour does not apply:
/// Whether or not the navigator created by this builder and it's new topmost route should request focus
/// when the new route is pushed onto the navigator.
///
/// Defaults to true.
final bool requestFocus;
RouterBuilder
(builder.dart) does not pass requestFocus
to the new Navigator
in build.
Expected results
child: Navigator(
key: widget.navigatorKey,
requestFocus: widget.requestFocus,
restorationScopeId: widget.navigatorRestorationId,
pages: _pages!,
observers: widget.observers,
onPopPage: _handlePopPage,
),
Actual results
child: Navigator(
key: widget.navigatorKey,
restorationScopeId: widget.navigatorRestorationId,
pages: _pages!,
observers: widget.observers,
onPopPage: _handlePopPage,
),
Code sample
Code sample
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
void main() {
debugFocusChanges = true;
runApp(MyApp());
}
final GoRouter _router = GoRouter(
requestFocus: false,
routes: [
GoRoute(
path: '/',
builder: (context, state) => const HomeScreen(),
),
],
);
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp.router(
routerConfig: _router,
title: 'GoRouter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
);
}
}
class HomeScreen extends StatelessWidget {
const HomeScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Home')),
body: const Center(child: Text('Welcome to the Home Screen!')),
);
}
}
Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
[Paste your logs here]
Flutter Doctor output
Doctor output
[Paste your output here]