@@ -237,6 +237,48 @@ void testMain() {
237237 expect (window.browserHistory.urlStrategy! .getPath (), '/foo' );
238238 });
239239
240+ test ('should not throw when state is complex json object' ,
241+ () async {
242+ // Regression test https://github.com/flutter/flutter/issues/87823.
243+ await window.debugInitializeHistory (TestUrlStrategy .fromEntry (
244+ const TestHistoryEntry ('initial state' , null , '/initial' ),
245+ ), useSingle: false );
246+ expect (window.browserHistory, isA <MultiEntriesBrowserHistory >());
247+
248+ // routeInformationUpdated does not
249+ final Completer <void > callback = Completer <void >();
250+ window.sendPlatformMessage (
251+ 'flutter/navigation' ,
252+ const JSONMethodCodec ().encodeMethodCall (const MethodCall (
253+ 'routeInformationUpdated' ,
254+ // ignore: prefer_const_literals_to_create_immutables
255+ < String , dynamic > {
256+ 'location' : '/baz' ,
257+ 'state' : < String , dynamic > {
258+ 'state1' : true ,
259+ 'state2' : 1 ,
260+ 'state3' : 'string' ,
261+ 'state4' : < String , dynamic > {
262+ 'substate1' : 1.0 ,
263+ 'substate2' : 'string2' ,
264+ }
265+ },
266+ },
267+ )),
268+ (_) { callback.complete (); },
269+ );
270+ await callback.future;
271+ expect (window.browserHistory, isA <MultiEntriesBrowserHistory >());
272+ expect (window.browserHistory.urlStrategy! .getPath (), '/baz' );
273+ final dynamic wrappedState = window.browserHistory.urlStrategy! .getState ()! ;
274+ final dynamic actualState = wrappedState['state' ];
275+ expect (actualState['state1' ], true );
276+ expect (actualState['state2' ], 1 );
277+ expect (actualState['state3' ], 'string' );
278+ expect (actualState['state4' ]['substate1' ], 1.0 );
279+ expect (actualState['state4' ]['substate2' ], 'string2' );
280+ });
281+
240282 test ('can replace in MultiEntriesBrowserHistory' ,
241283 () async {
242284 await window.debugInitializeHistory (TestUrlStrategy .fromEntry (
0 commit comments