Hello All . To use Flutter, you have to master the Dart Programming Language. I would like to share my observations while learning Dart Programming Language.
Mixins are used to reuse multiple inheritance style classes. Unlike inheritance, it cannot be used if it contains constructors. As a PHP user, if you understand the Trait Pattern, Dart will understand the Mixins.
Let us write an example with Dragon Knight.
Mixins
mixins.dart
Dart programming for our Future. We can use dart for multi platform app developing.
void main () {
print ("Junta!");
var dog = Dog ("Aung Hlaing", "red");
dog.eat ();
dog.bark ();
print (dog.legs);
dog.runWithFourLegs ();
}
class Canis {
int legs = 4;
void runWithFourLegs () {
print ("Run with 4 Legs");
}
}
class Animal {
String name;
String color;
Animal (this.name, this.color);
void eat () {
print ("EAT!");
}
}
class Dog extends Animal with Canis {
Dog (String name, String color): super (name, color);
void bark () {
print ("WOOF!");
}
}
In Dog Class, the term with Canis is Mixins. This allows you to use the legs property and the runWithFourLegs () method.
Async and Await
Another thing I immediately noticed was Async and Await. In Kotlin, Dart has a built-in feature that only works with Coroutine. Coroutine uses Deferred <>, but Dart uses Future <>.
Let us write an example with Dragon Knight.
async.dart // You can save and run on dartpad.dev website.
void main () {
var testAsync = TestAsync ();
testAsync.printWithDelay ("Hello Async Dart!");
}
class TestAsync {
static const fiveSecond = Duration (seconds: 5);
Future <void> printWithDelay (String message) async {
await Future.delayed (fiveSecond);
print (message);
}
}
Pure Object Oriented Programming Language
Dart is a class-based, single-inheritance, pure object-oriented programming language. Every variable is an object. Once we declare a variable, we need to understand that it is inherited from the Object class. In Kotlin we have to extend the class Any. Let us give you a sample
variable_type.dart // save and run on dartpad.dev
void main () {
int count = 5;
if (count is Object) {
print ("Count is an object");
} else {
print ("Count is not an object");
}
}
Count will always be an object. In Kotlin, if you write Android, you can use primitive data types as objects in Java, but when you get to Java, they will be primitive data types.
Sharing is Caring.
can’t catch up this language
😁😁😁
Many secrets are not understood😁😁
Thank u ao much par shin🐬🐬
Thanks for your sharing.