Created
January 31, 2023 14:59
-
-
Save LokieVikky/b0e013950d5fb4014f6d6edb5a294a48 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
Remote r = Remote(); | |
r.numberOfButton = 20; | |
print(r.numberOfButton); | |
Remote r2 = Remote(); | |
print(r2.numberOfButton); | |
// positional argument | |
r.gotoChannel(1); | |
// String interpolation | |
print('Number of buttons ${r.numberOfButton}'); | |
r.play(); | |
r.play(num: 6); | |
r.pause(num: 6); | |
r.printSomething(3, 4, 5, '', '', ''); | |
r.printSomething1(b: 4, a: 4); | |
} | |
class Remote { | |
int numberOfButton = 10; | |
// returnType functionName(){} | |
void turnOn() { | |
print('Turn On Called'); | |
} | |
void turnOf() { | |
print('Turn off Called'); | |
} | |
// positional argument | |
void gotoChannel(int num) { | |
// String interpolation | |
print('Changed channel to $num'); | |
} | |
// named argument / optional argument | |
void play({int? num}) { | |
// String interpolation | |
print('Changed channel to $num'); | |
} | |
// named required argument | |
void pause({required int num}) { | |
print('paused ' + num.toString()); | |
} | |
void printSomething(int a, int b, int c, String aa, String bb, String cc) { | |
print('Something'); | |
} | |
void printSomething1( | |
{required int a, int? b, int? c, String? aa, String? bb, String? cc}) { | |
print('Something'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment