Meaning of ' .. ' vs ' . ' in dart

Advertisements

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?

>Solution :

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!'));

Leave a ReplyCancel reply