Open NiceGuyNimni opened 1 week ago
@NiceGuyNimni can you share example when you are seeing this issue?
Sure @ndesai-newrelic
This is the simplest widget I render on screen (DummyView). I use go router in my project. First you need to click the 'Open dialog' button and then when I click 'OK' it tries to navigate to a new route and throws an exception inside the observer.
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:wiziwill_app/utils/config.dart';
class DummyView extends StatelessWidget {
const DummyView({super.key});
@override
Widget build(BuildContext context) {
return TextButton(onPressed: () {
showDialog<String>(
barrierDismissible: false,
context: context,
builder: (BuildContext context) => PopPopPop(),
);
}, child: Text('Open dialog'));
}
}
class PopPopPop extends StatelessWidget {
const PopPopPop({super.key});
@override
Widget build(BuildContext context) {
return AlertDialog(
title: const Text('Here we go...'),
icon: Icon(
Icons.error_outline,
color: Colors.red,
size: 18.0,
),
content: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Text(
'Something went wrong but we\'re on it.'),
],
),
),
actions: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
TextButton(
onPressed: () {
context.go(Routes.main);
},
child: const Text('OK'),
),
],
)
]);
}
}
When navigating to a new route from a dialog the navigation observer tries to get the 'key' key of the fromRoute which is an instance of DialogRoute and thus does not have such key and that throws an exception.
https://github.com/newrelic/newrelic-flutter-agent/blob/49a3f05e4687a79778a9dc6194209d881d32f60b/lib/newrelic_navigation_observer.dart#L84