'first its coming the result after changes some code then its showing like Expected a value of type 'Map<dynamic, dynamic>', but got one of type Null
9:41 AM {location: Berlin, flag: germany.png, time: 9:41 AM} Restarted application in 4,422ms.
════════ Exception caught by widgets library ═══════════════════════════════════ The following TypeErrorImpl was thrown building Home(dirty, dependencies: [_ModalScopeStatus], state: _HomeState#b1e1d): Expected a value of type 'Map<dynamic, dynamic>', but got one of type 'Null'
The relevant error-causing widget was Home lib\main.dart:14 When the exception was thrown, this was the stack enter image description here
Solution 1:[1]
Hope Coding Well Go fine...
In Flutter if we want to pass arguments between our Widgets we Because we are on Null safty so try to pass value as it data type such as..
For example here we are taking named Route.
for 1st Screen
Map value={....};
Navigator.PushNamed('Named of page' , argument : value!=null ? value : {'Key' : 'Value is null'} );
Second Screen
final Map argument = ModalRoute.of(context)?.settings.arguments;
NOTE: Try not to bind values as dynamic bind them as there datatype hope it will solve your issue..
Solution 2:[2]
Declare your Map optional Map? data = {}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ameer Hamza |
| Solution 2 | Kai - Kazuya Ito |
