0

Can anyone explain what's the difference between

create: (context) => AppBloc()..add(event: AppStarted())),

vs

create: (context) => AppBloc().add(event: AppStarted())),

The only difference is the ..

What does this mean?

user3840170
  • 26,597
  • 4
  • 30
  • 62
austin
  • 517
  • 5
  • 16

1 Answers1

1

In very simple words... the .. (Cascade Notation) is used chain functions together.

Example:

// with cascade notation:
querySelector('#confirm') // Get an object.
  ..text = 'Confirm' // Use its members.
  ..classes.add('important')
  ..onClick.listen((e) => window.alert('Confirmed!'))

// without cascade notation
var button = querySelector('#confirm');
button.text = 'Confirm';
button.classes.add('important');
button.onClick.listen((e) => window.alert('Confirmed!'));
Anand
  • 323
  • 1
  • 8
  • I'd say it even simpler than that. The result of a.b is the return value of b. The result of a..b is a, after calling a.b and discarding its result. – Randal Schwartz May 19 '23 at 15:51