This is an old revision of the document!
Flutter
POO
Constructeur avec paramètres nommés
class Test {
// ...
// Test(foo: 'foo', bar: 'bar');
Test({ String foo, String bar})
}
Constructeur avec paramètres nommés & obligatoires
class Test {
// ...
// Test(bar: 'bar') => throw an exception because foo does not exist
Test({ required String foo, String bar})
}
Surcharger un constructeur
class Test {
// ...
Test({super.key, this.foo});
Test.foo({super.key}) {
foo = 'foo';
}
}
Librairies externes
Paramètres nommés requis: ({ @required String foo, String bar }) ⇒ foo obligatoire Classname({ this.foo, this.bar }) ⇒ shortcut
Surcharger un constructeur: class Person {
String name; int age;
Person({this.name, this.age})
Person.newBorn({this.name}) {
this.age = 0;
}
}
Widgets: * SafeArea pour ignorer le haut du device Librairie: * smooth_page_indicator