Mahdi-Malv
Mahdi-Malv

Reputation: 19308

Call function after other functions in Dart

How can we invoke methods like:

MyClass obj = new MyClass();
obj.fun1().fun2()....;

Just like alertDialog in Android.

new AlertDialog.Builder(this).setTitle().create().show();

Thanks in advance.

Upvotes: 1

Views: 49

Answers (1)

Maximilian Riegler
Maximilian Riegler

Reputation: 23526

That's basically the builder pattern, where your methods return this, but you can do that even prettier in Dart with Method cascades:

MyClass obj = new MyClass()
  ..fun1()
  ..fun2()
  ..fun3();

Upvotes: 6

Related Questions