-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
flutter/packages
#5288Closed
Copy link
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: null-safetySupport for Dart's null safety featureSupport for Dart's null safety featurefound in release: 2.10Found to occur in 2.10Found to occur in 2.10found in release: 2.13Found to occur in 2.13Found to occur in 2.13has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: go_routerThe go_router packageThe go_router packagepackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.
Description
copied from csells/go_router#385
The extra from GoRouterState is null when the Widget inspector is open with the toggle SELECT WIDGET MODE is enabled and the current page extract data from the GoRouterState (extra).
Code to reproduce this issue:
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
void main() {
runApp(const MyApp());
}
GoRouter _router = GoRouter(
initialLocation: '/splash',
debugLogDiagnostics: true,
observers: [],
routes: [
GoRoute(
path: '/splash',
pageBuilder: (context, state) => CustomTransitionPage<void>(
key: state.pageKey,
child: const SplashPage(),
transitionsBuilder: (context, animation, animation2, child) {
return FadeTransition(
opacity: animation,
child: child,
);
},
),
),
GoRoute(
name: 'login',
path: '/login',
builder: (context, state) => LoginPage(user: state.extra! as String),
),
],
);
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp.router(
routeInformationParser: _router.routeInformationParser,
routerDelegate: _router.routerDelegate,
theme: ThemeData(
primarySwatch: Colors.blue,
),
);
}
}
class SplashPage extends StatefulWidget {
const SplashPage({Key? key}) : super(key: key);
@override
State<SplashPage> createState() => _SplashPageState();
}
class _SplashPageState extends State<SplashPage> {
Future<void> _checkSplash() async {
await Future.delayed(const Duration(seconds: 2));
context.go('/login', extra: "Diego");
}
@override
void initState() {
_checkSplash();
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
backgroundColor: Colors.white,
body: const Center(
child: CircularProgressIndicator(),
),
);
}
}
class LoginPage extends StatefulWidget {
const LoginPage({required this.user, Key? key}) : super(key: key);
final String user;
@override
State<LoginPage> createState() => _LoginPageState();
}
class _LoginPageState extends State<LoginPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('LOGIN'),
),
body: Center(
child: Text('user: ${widget.user}'),
),
);
}
}ezra-gunn, maxlapides, diegoveloper, chradcliffe, heeyunlee and 22 moremr7ssam, letyletylety, definev and punzar
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: null-safetySupport for Dart's null safety featureSupport for Dart's null safety featurefound in release: 2.10Found to occur in 2.10Found to occur in 2.10found in release: 2.13Found to occur in 2.13Found to occur in 2.13has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: go_routerThe go_router packageThe go_router packagepackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.