xxxxxxxxxx
// Creating Class named Schema
class Schema {
String name='';
int date='';
}
void main()
{
// Creating Instance of class
var newSchema = new Schema();
newSchema.name= 'motor'
}
xxxxxxxxxx
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});
}
xxxxxxxxxx
class Car {
// field
String engine = "E1001";
// function
void disp() {
print(engine);
}
}
xxxxxxxxxx
Mixins are a way of reusing a class’s code in multiple class hierarchies.
To use a mixin, use the with keyword followed by one or more mixin names. The following example shows two classes that use mixins:
class MyClass with MyMixin {
// ···
}
To implement a mixin, create a class that extends Object and declares no constructors.
Unless you want your mixin to be usable as a regular class, use the mixin keyword instead of class.
For example:
mixin MyMixin {
// ···
}