fold<T> method
T
fold<T>(
- T whenTrue,
- T whenFalse
Returns whenTrue if this boolean is true, and whenFalse if this boolean is false.
bool isDark = true;
String result = isDark.fold('dark', 'light');
print(result); // 'dark'
Implementation
T fold<T>(T whenTrue, T whenFalse) => this ? whenTrue : whenFalse;