Skip to content

Instantly share code, notes, and snippets.

@bwnyasse
Last active November 12, 2023 00:13
Show Gist options
  • Save bwnyasse/13f1e35464ea6d35feffb8ee754c5aec to your computer and use it in GitHub Desktop.
Save bwnyasse/13f1e35464ea6d35feffb8ee754c5aec to your computer and use it in GitHub Desktop.
/*
* Dart & Flutter - Training
*
* Copyright (c) Boris-Wilfried Nyasse
* All rights reserved
*
*/
class Demo {
num? width;
num? height;
void updateWidth(num x) {
width = x;
}
void updateHeight(num y) {
height = y;
}
void showValues() {
print(width);
print(height);
}
}
class Div {
String? width;
String? height;
String? padding;
@override
String toString() => "width:$width, height:$height, padding:$padding";
}
class Html {
static Div div() => Div();
}
void main() {
Demo d1 = Demo();
Demo d2 = Demo();
print("Formation Dart & Flutter - Cascade Notation");
print('// Without Cascade Notation');
d1.updateWidth(20);
d1.updateHeight(25);
d1.showValues();
final div1 = Html.div();
div1.width = '50%';
div1.height = '4em';
div1.padding = '1em';
print(div1);
print('// With Cascade Notation');
d2
..updateWidth(10)
..updateHeight(15)
..showValues();
final div2 = Html.div()
..width = '50%'
..height = '4em'
..padding = '1em';
print(div2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment