Skip to content

Instantly share code, notes, and snippets.

@bradmartin333
Created June 30, 2025 16:22
Show Gist options
  • Save bradmartin333/0ae6535bfda8b5b22de4da0e9e8f9849 to your computer and use it in GitHub Desktop.
Save bradmartin333/0ae6535bfda8b5b22de4da0e9e8f9849 to your computer and use it in GitHub Desktop.
dart ternary formatting example
import 'dart:math';
enum AppRoute { root, login, welcome }
void main() {
final randomNumberGenerator = Random();
final isAuthenticated = randomNumberGenerator.nextBool();
final hasSeenWelcome = randomNumberGenerator.nextBool();
final initialLocation = isAuthenticated
? AppRoute.root
: hasSeenWelcome
? AppRoute.login
: AppRoute.welcome;
print(initialLocation);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment