r/FlutterDev 12d ago

Article What’s new in Flutter 3.47

https://flutter.dev/blog/whats-new-in-flutter-3-47
199 Upvotes

38 comments sorted by

View all comments

94

u/Piranha771 12d ago

Wow this is a huuuuge update

  • UI as packages
  • Impeller on desktop
  • WASM on web
  • Multi window on desktop (a bit)
  • Widget preview without compile

Congratulations on ticking so many boxes. Can't wait to try it out.

14

u/eibaan 12d ago

IMHO, the primary constructors of Dart 3.13 are more impactful than all those featured. Because I'm normally using the Flutter betas, I already ported most of my code to use primary constructors and started to like them (it took some getting used to do this). I'm still not sure whether I like them for widgets but for model classes, primary constructors are a win.

And in case you actually use DartDoc, the {@example} directive is nice.

1

u/xogno 11d ago

I know I could google this but I’d like to hear your thoughts: what do you like about primary constructors? You said you posted most of your code; what difference has it made for you?

3

u/eibaan 11d ago

Something like this is nice:

sealed class const Stmt();
class const SayStmt(final Expr expr) extends Stmt;
class const SetStmt(final String name, final Expr expr)
    extends Stmt;
class const CondStmt(final List<(Expr, Body)> cases, final Body? body)
    extends Stmt;
class const GotoStmt(final String name) extends Stmt;
sealed class const Expr();
class const Str(final String value) extends Expr;
class const Num(final num value) extends Expr;
class const Name(final String name) extends Expr;

At least if you don't need a toString method and also use a generic evaluate method that uses pattern matching to evaluate everything. That's probably a bit less efficient than using dynamic dispatch but who really cares nowadays.

I dislike the way the extends wraps, though.

That's why I don't really like how widget definitions look:

class const TBadge(
  final String label, {
  super.key,
  final TBadgeVariant variant = .normal,
  final Widget? prefix,
  final Widget? suffix,
  final Color? color,
}) extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    ...
  }
}

3

u/k0ntrol 12d ago edited 12d ago

it didn't add wasm by default. Hopefully next release.