Following the map, having both key-value pair as dynamic, Write a logic to filter all the null values from Map without us?
Is there any other approach than traversin
You can now use a map literal with conditional entries:
Map toMap() => { if (firstName != null) 'firstName': firstName, if (lastName != null) 'lastName': lastName, };