Skip to content

Instantly share code, notes, and snippets.

@samanzamani
Created March 21, 2019 10:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samanzamani/273b206a094e796caa344430c2433146 to your computer and use it in GitHub Desktop.
Save samanzamani/273b206a094e796caa344430c2433146 to your computer and use it in GitHub Desktop.
Sample class and function in Dart
class MyClass{
String str = '';
MyClass(this.str);
}
void main() {
MyClass obj1 = MyClass('obj1 initial');
print(obj1.str);
doSomething(obj1);
print(obj1.str);
obj1 = doSomethingElse(obj1);
print(obj1.str);
}
void doSomething(MyClass obj){
obj.str = 'obj1 new string';
}
MyClass doSomethingElse(MyClass obj){
return MyClass('obj1 new object');
//OR => return obj..str = "obj1 new object";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment