3 ms·
> The other is an interesting quality-of-life change for Flutter developers, which allows creating an instance of a class without the “new” keyword. The goal of
by syspec 8y ago
> The other is an interesting quality-of-life change for Flutter developers, which allows creating an instance of a class without the “new” keyword. The goal of this change is to make Flutter code more readable, less clunky, and easier to type
Wait, not typing new accomplishes all those amazing things? Here i thought it was just three letters, which showed intent - hence easier to grok the surrounding code
- lasagnaphil 8y agoWhen you’re creating a big tree of component objects in pure code (without DSLs, macros, or something like JSX), omitting the new keyword is pretty nice.
- losvedir 8y agoYou'd be surprised. In Flutter you construct new objects _all the time_ and mostly inline (think React without JSX). The `new`'s really do get tedious when you're making a tree like: Container( child: Column( children: [ Text("One"), Text("Two"), Text("Three"), ] ) ) It's not major but I don't think your quote is overselling it either. It is a quality-of-life change that does those things.
- munificent 8y ago> which showed intent - hence easier to grok the surrounding code There was some concern that removing "new" would make it less obvious that an object was being constructed. In practice, though, it's been totally fine. The fact that the thing you're invoking is a class (and hence a capitalized name) seems to be sufficient signal that "you're making an object". Also, several other languages already work this way: Python, Scala, Kotlin, etc.
- monocularvision 8y agoAnd Swift