Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR DART

Dart class structure

class Person {
  String name = 'Lara';
  int age = 12;
  
  Person({this.name = '',  this.age = 18});
  
}


int addNumbers(int num1, int num2) {
  return num1 + num2;
}

void main() {

  var p1 = Person(name: 'Gabriel', age: 18);
  var p2 = Person(name: 'Clara', age: 29);
  
  print({'name': p1.name, 'age': p1.age});
  print({'name': p2.name, 'age': p2.age});
    
  
}

Source by dartpad.dev #
 
PREVIOUS NEXT
Tagged: #Dart #class #structure
ADD COMMENT
Topic
Name
7+2 =