01 Advanced Mobile Programming 2021 - Introduction
01 Advanced Mobile Programming 2021 - Introduction
Customize your app with Material Design, themes, assets, and more
Make your app interactive with text input, gestures, and more
Learning outcomes
After Completing this course you should be able to
https://flutter.dev/
Benefits of using Flutter
Fast Development
Flutter's hot reload helps you quickly and easily experiment, build UIs,
add features, and fix bugs faster
https://flutter.dev/showcase
Benefits of using Flutter
Native Performance
Thus Flutter gives you full native performance on both iOS and
Android
How to set up development platform
Go to https://flutter.dev/docs/get-started/install and follow the
instruction for your platform
Set up an editor
Option One (https://flutter.dev/docs/get-started/editor?tab=androidstudio)
Install VS Code
https://dart.dev/
Benefits of using Dart
Optimized for UI
Productive development
Make changes iteratively: use hot reload to see the result instantly in
your running app
https://dart.dev/
Benefits of using Dart
Fast on all platforms
Compile to ARM & x64 machine code for mobile, desktop, and
backend
https://dart.dev/
Brief introduction to Dart
Dart language features
https://dart.dev/samples
Hello World
Every app has a main() function
To display text on the console, you can use the top-level print() function
void main() {
print('Hello world');
}
Variables
Even in type-safe Dart code, most variables don’t need explicit types,
thanks to type inference
void main() {
print(add(2,3));
}
Recommended way of defining functions
add(x, y) { int add(int x, int y) {
return x+y;
return x+y;
}
}
Functions
A shorthand => (arrow) syntax is handy for functions that contain a single
statement
void main() {
print(add(2,3));
}
int add(int x, int y) => x+y;
Comments
// This is a normal, one-line comment.
supported */
Imports
// Importing core libraries
import 'dart:math';
// Importing files
import 'path/to/my_other_file.dart';
Class
import 'dart:math'; Class with two properties, two
class Circle { constructors, one method and
one getter method
double _radius;
static const double PI = 3.14;
Circle(this._radius);
Circle.inMeter(this._radius);
double area() => PI * pow(_radius, 2);
get radius => _radius;
}
Class
import 'dart:math'; Class with two properties, two
class Circle { constructors, one method and
one getter method
double _radius;
static const double PI = 3.14;
Circle(this._radius); Constructors
Circle.inMeter(this._radius);
double area() => PI * pow(_radius, 2);
get radius => _radius;
} Getter
Inheritance
Dart has single inheritance class Circle extends Shape {
double _radius;
abstract class Shape {
static const double PI = 3.14;
double area();
}
Circle(this._radius);
@override
double area() => PI * pow(_radius, 2);
get radius => _radius;
}
Mixins
Mixins are a way of reusing code in multiple class hierarchies
void main(){
int x, y;
void main() {
int x = 1, y = 0;
try {
x / y;
} catch (IntegerDivisionByZeroException) {
print('Y cannot be zero');
}
}
Assessments
Laboratory Assignments (total mark 15 - 20 points)
Project ( 20 to 25 points)
You should have a backend (REST API) that provide the two functionality