Check out example codes for "StateError (Bad state: No element)". It will help you in understanding the concepts better.

Code Example 1

// Use the orElse and set it to null.
someIterable.firstWhere(test, orElse: () => null);

Learn ReactJs, React Native from akashmittal.com