Mobile
Mobile
Definition: Apps built using one codebase for multiple platforms (Android & iOS).
Frameworks:
React Native (JavaScript)
Flutter (Dart)
.NET MAUI/Xamarin (C#)
Examples:
React Native: Instagram, Skype .. etc
Flutter: Google Ads, eBay Motors, New York Times
Xamarin: The World Bank, Alaska Airlines
Pros:
Lower cost (one development team)
Faster development (code reusability)
Easier maintenance (single codebase)
Cons:
Larger app size
Harder to integrate some hardware features
Lower performance than native apps
Delayed support for new platform features
The Dart language is designed to be easy to learn for coders coming from
other languages, but it has a few unique features. This tutorial walks you through
the most important of these language features.
String interpolation
'${"word".toUpperCase()}' 'WORD'
class Person {
String name;
String email;
String phone;
void main() {
Person p = Person( "Nour Ahmed" , "[email protected]" , "01011111111");
print(p); //output: Instance of 'Person'
}
******************
class Person {
String name;
String email;
String phone;
@override
String toString() {
void main() {
Person p = Person( "Nour Ahmed" , "[email protected]" , "01011111111");
print(p);
}
______________________________________________
stringify(10 , 10 )
//output '10 10'
Nullable variables
Dart enforces sound null safety. This means values
can't be null unless you say they can be. In other
words, types default to non-nullable.
__________Example_______________
void main() {
String ? name = 'Nour Ahmed';
String ? address;
try {
if (name == 'Nour Ahmed' && address == null)
{
// verify that "name" is nullable
ll
name = null;
print('Success!');
}
else {
print('Not quite right, try again!');
}
}
catch (e) {
print('Exception: ${e.runtimeType}');
}
}
Null-aware operators
Dart offers some handy operators for dealing with values that might be null.
One is the ??= assignment operator, which assigns a value to a variable only if
that variable is currently null:
______ Ex 1________
int ? a ; // = null
a ??= 3;
print(a); // <-- Prints 3.
a ??= 5;
print(a); // <-- Still prints 3.
myObject?.someProperty;
{ return myObject.someProperty ; }
Collection literals
return s.isEmpty;
});
Cascade
class Item {
int id;
double price;
Item(this.id, this.price);
void discount(double discount) {
@override
String toString() {
void receipt() {
void main() {
print (item );
item..discount(10) ..receipt();
}
output
1- Positional parameters
int sum = a;
if (b != null) sum += b;
if (c != null) sum += c;
return sum;
// ···
void main() {
2- Named parameters
void main() {
printName('Dash', 'Dartisan');