-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
flutter/packages
#9177Closed
Copy link
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterf: routesNavigator, Router, and related APIs.Navigator, Router, and related APIs.good first issueRelatively approachable for first-time contributorsRelatively approachable for first-time contributorsp: go_routerThe go_router packageThe go_router packagepackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.
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]Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterf: routesNavigator, Router, and related APIs.Navigator, Router, and related APIs.good first issueRelatively approachable for first-time contributorsRelatively approachable for first-time contributorsp: go_routerThe go_router packageThe go_router packagepackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.