Created
September 24, 2025 19:20
-
-
Save JohanScheepers/7848dbc4e2fff4ddaf1471d320d38c70 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class OpinionOnDart { | |
| const OpinionOnDart({ | |
| required this.love, | |
| this.hate, | |
| }); | |
| final String love; | |
| final String? hate; | |
| void express() { | |
| // I love Dart's type safety, which ensures 'love' is never null. | |
| print('What I love: $love'); | |
| // I use the if-null operator (??) to provide a default value | |
| // in case there's nothing to hate. | |
| print('What I hate: ${hate ?? 'Nothing at all! Dart is great.'}'); | |
| } | |
| } | |
| void main() { | |
| // My opinion is constant and unchanging. | |
| const myOpinion = OpinionOnDart( | |
| love: 'Its expressive syntax, incredible performance on multiple platforms (from mobile to web), and a developer-friendly, pragmatic approach to building software.', | |
| // The 'hate' property is null, so there are no complaints. | |
| ); | |
| myOpinion.express(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment