Method Cascading In Flutter

Method Cascading In Flutter :

Method cascading is syntax which allows multiple methods to be called on the same object. sDart implements cascades, using a double-dot .. “cascaded method invocation operation”.

building complex objects (lots of property configuration)
making objects better for encapsulation. return this makes objects too open.
building objects faster with nested cascade.
less lines of code.

Method Cascading In Flutter
class Student { 
   void test_method() { 
      print("This is a  test method"); 
   } 
   
   void test_method1() { 
      print("This is a  test method1"); 
   } 
}  
void main() { 
   new Student() 
   ..test_method() 
   ..test_method1(); 
}

var address = getAddress();
address.setStreet("", "");
address.city = ""
address.state = ""
address.zip(66666, extended: 6666);

getAddress()
  ..setStreet("", "");
  ..city = ""ss
  ..state = ""
  ..zip(66666, extended: 6666);


class ChainCalculator {
  double _accumulator = 0.0;

  ChainCalculator(double initVal) {
    this._accumulator = initVal;
  }

  ChainCalculator add(double val) {
    this._accumulator += val;
    return this;
  }

  ChainCalculator subtract(double val) {
    this._accumulator -= val;
    return this;
  }

  double result() {
    return this._accumulator;
  }
}

Calculator calculator = Calculator(0.0)
    ..add(12.0)
    ..subtract(10.0)
    ..add(5.0)..subtract(8.0);

print("Result: " + calculator.result().toString());

The flutter tutorial  is a website that bring you the latest and amazing resources of code. All the languages codes are included in this website. The languages like flutter, android, java,kotlin etc.with the help of this languages any user can develop the beautiful application

For more information about Flutter. visit www.fluttertutorial.in