escamoteur / watch_it

MIT License
103 stars 8 forks source link

ChangeNotifier Example in Readme - Syntax Error? #5

Closed cliftonlabrum closed 11 months ago

cliftonlabrum commented 11 months ago

Flutter 3.10.5 and Dart 3.0.5

The initial example on the Pub.dev listing shows:

// Create a ChangeNotifier based model
class UserModel extends ChangeNotifier {
  get name = _name;
  ...
}

When I use the get name = _name; syntax, I see this error:

Only factory constructor can specify '=' redirection.

If I add the type and a shorthand return arrow, it works:

String get name => _name;

I may be doing something wrong, but I just wanted to note this. 😄

escamoteur commented 11 months ago

Oh, thanks a lot, that should definitely be a =>