Application development is the process of creating a computer program or a set of programs to perform the different tasks that a business requires. From calculating monthly expenses to scheduling sales reports, applications help businesses automate processes and increase efficiency.
Mobile application development is the process of creating software applications that run on a mobile device, and a typical mobile application utilizes a network connection to work with remote computing resources.
- Native Application Development.
- Web based Application Development.
- Hybrid Application Development.
Native Application are designed to run an particular platform such as Andriod, Windows or ios.
Web based applications are written in HTML, CSS, JAVASCRIPT. To use this application youβll need internet connection.
Hybrid application is a combination of both Native and Web-based Applications.
Dart is a client-optimized language for developing fast apps on any platform. Its goal is to offer the most productive programming language for multi-platform development, paired with a flexible execution runtime platform for app frameworks.
A 'player' can throw this "dart arrow" to the 'dart board' during 'dart game'. We think of the dart arrow as being the Dart language, the dart player as the Dart Developer, and the dart board as being the entire eco-system of the dart based apps.
-
Precision -
Language has to be as optimised as possible. -
Speed -
Language has to be minimalist and fast to run. -
Tough -
Language has to be scalable, maintainable and readable. -
Modifiable -
Language has to benifit of fast hot reload. -
Popular Framework -
Language is the foundation of Flutter.
These are the core features of Dart programming language. Str
The Dart SDK has the libraries and command-line tools that you need to develop Dart web, command-line, and server apps. To get the Dart SDK, see Get Dart. If you're developing Flutter apps, then you don't need to separately download the Dart SDK; just install Flutter.
To Install Dart - https://medium.com/yavar/dart-bc897f1df1dd
dart create -t console-full console_full-project
cd console_full-project
dart run
The Dart compile will compiler the dart file, which is inside the bin folder.
- Run the command :
dart pub global activate devtools
-
Add the file path in Environment variables.
-
Then run the command :
dart run --observe --pause-isolates-on-start
- Open a new terminal and run the command given below, once you run the command the
devtools
will open on your browser.
devtools
-
Copy the VM service is listening on [...url...] and paste it on the
devtools
. -
Connect the url to the
devtools
.
Dart is a Type Safe Language, the only operations that can performed on data in the language, are those allowed by type of the data. For example if we've an variable int x
is not allowed to perform the String Operations
like toUpperCase() or toLowerCase()
, since the String
types doesn't support integer operations
.
-
The Sound type system won't allow the code to run into undefined states, but exactly it is called as
SOUND
. -
The Dart having the both
Static Type Check
andRuntime Check
. These are mainly used to find the error in the code or error in the time of compilation.
Whenever we use dynamic
type the static analyzer won't care about that data anymore.
Types are Mandatory but don't have to be annotated, because dart can INFER TYPES by using the var
keyword. When we assign a value to an variable with var
keyword, it automatically assign the type also.
Variables can't contain NULL
, unless you say they can. If the dart variable is NON-NULLABLE that variable will always be NON-NULLABLE. NON-NULLABILITY is retained at RUNTIME!. Null Safety is really important in dart programmin
The Dart Compiler is a compiler which is a tool that converts the source code you wrote in dart language into other intermediate languages or machine code that ca n run on a specific platform in dart virtual machine. However dart uses different compilers for different jobs.
During the project there should be two phases :
-
Development Phase.
-
Production Phase.
-
JIT, which stands for Just In Time Compiler. Just In Time Compiler as its name is implying compiles just the amount of code it needs.
-
For example : If our project having 10,000 lines of code, it won't compile enitire code, it only compile the required set of code.
-
JIT also comes with an incremental recompilation.
-
Jit does not transform the dart code into machine code, but rather into an intermediatary language (For Faster Development Cycles).
-
The JIT was mainly designed for Development Phase.
-
AOT, Which stands for Ahead of Time Compiler.
-
The Ahead of Time Compiler, compiles entire source code into a machine code supported natively by the platform.
-
The AOT compiler is mainly designed for Production Phase.
-
The dart package is the main component of dart ecosystem, there is a place, where all dart developer were publish their dart packages called
pub.dev
. -
The main use of packages is to 'Retrieve data from an API', 'Parse the JSON inside the APP', and 'Store the data to a local Database'.
-
We can also use already existing packages, each packages have an different features.
-
Our dart project is a standalone dart package.
A composable, Future-based library for making HTTP requests.It mainly used to retrieve data from an API by using this package.
It Provides Dart Build System builders for handling JSON. It is mainly used to Parse the JSON inside the APP.
Hive is a lightweight and blazing fast key-value database written in pure Dart. It is mainly used to store the data to a local Database.
The Package that won't be uploaded in the pub.dev
is known as Application package
and the package that will be uploaded into pub.dev
is known as Library package
.
-
The Relationship between package and library is that the package can contain one or multiple libraries.
-
The Libraries are the only part that is publicaly accessible to everyone.
The Dart Linter package defines lint rules that identify and report on lints
found in Dart code. Linting is performed by the Dart analysis server and the dart analyze command in the Dart command-line tool.
-
The Dart Tests represents the one of the pillars that add a lot of value onto the development and maintaince aspects of a project
-
They are the pieces of code that we write in order to make sure the features and implementatoions
-
We coded behave and output things as expected ideally for every features or added functionallity we should test checking if it's working good or not in dart test are written inside the test folder in files appending underscore.test at the end in pour case, we have a test verifying if the putput of the caculate function is really expected number of 42.
-
This is called a unit test adn the simplest test we can write but how do we run it as you have probably guessed by now you can do it from inside the editor or from inside the dart cli.
-
Inside the editor we actually have a dedicated panel we can go to called testing at the top we have multiple button to run the tests.
-
Inside the
dart cli
run a commanddart test
to run full tests.
A Dart VM is a Virtual machine in a sense that it provides an execution environment for our Dart Programming Language.
The Dart Apps, Programs, and Packages are run inside the Dart VM
- The RUNTIME System.
- Development Experience Components.
- Debugging.
- Hot Reload.
- JIT & AOT Compilation Pipelines.
-
The Heap is the Garbage Collection managed memory storage for akk the objects allocated by the code running in the specific isolate, the garbage collector attemps to reclaim memory which was allocated by the program but it no longer referenced.
-
Each isolate has single mutator thread which executes but benifits from multiple helper threads which handle VM's internal tasks.
- From Source by using JIT/AOT Compiler
- From Snapshots(jit, aot or kernal snapshots).
-
The Dart VM doesn't have the ability to execute raw dart code, instead it expects some kernal binares also called dill files which contains serialized kernal abstract syntax tree as known as kernal ast. The kernal ast is actually based on this intermediatary language
-
The Dart Kernal is a small high-level intermediary language derived from dart Language.
-
The Task of translating dart souce code into kernal ast is handled by a dart package called the Common Frontend or CFE.
-
The process of the aot compilation does global static analysis called
Type Flow Analysis
or alos calledTFA
.
A Dart snapshot is just a binary serialization of the token stream, generated from parsing the code. A snapshot is not a "snapshot of a running program", it's generated before the tokens are turned into machine code. So, no program state is captured in a snapshot.
A Dart Snapshots contains an efficient representation of all those entities allocated on the dart VM Heap
.
Entities which are need to start an execution process.
Currently there are three snapshot types :
-
JIT - Snapshot.
-
AOT - Snapshot.
-
Kernal - Snapshot.
-
In Kernal Snapshots, there is no parsed classes, functions.
-
No Architecture specific code.
-
It is portable around all architecture.
-
Dart VM will need to compile it from scratch.
-
Create an
pubspec.yaml
file. -
And then add name and environment there.
-
Then run a command:
dart pub get
Then it automatically create some files.
There some protocol to publish packages in pub.dev
.
There two types of Dependencies :
-
Regular Dependencies.
In Regular dependencies we'll use in the both Development phase and Production phase.
-
Dev Dependencies. In Dev Dependencies it only used in the Development phase and ignore in the production phase.
The Dart language comes with sound null safety. Null safety prevents errors that result from unintentional access of variables set to null.
For example, if a method expects an integer but receives null , your app causes a runtime error. This type of error, a null dereference error, can be difficult to debug.
Types in your code are non-nullable by default. = variable can't conatin null, unless you say they can.
Runtime null errors turn into edit-time analysis errors = fasted way to observe and fix any issues.
Null Safety's goal is not a eliminate the null from the equation
- Null will still exist in every dart program
- Null highlights the "Absence" of the value.
- The issuse is not null itself, but rather having null where you don't expect it!
- Null Safety's goal is to have a control into where, how and when null can flow through your program.
- Types are mage Nullable by postfixing them with the question mark (?)
- For Example : String ?, int ?, double ?, num ?, List<int ?>
- Implicit Downcasts got removed.
- You can't access the base type props or methods with its nullable type
- The only props available for nullable types are toString(), == & hashCode In null safety, an object of any type is of type Object?
- The Never type was added a the bottom of the type tree and can be used to intterupt the flow of an application, by throwing an Exception
- Non-void non-Nullable functions must always return the correct non-nullable type.
- Non-nullable top-level variables & static fiels must always be initilized when declared.
- Non-nullable class fields must be initialized before the constructer body.
- Non-nullable optional parameters must be initialized in the parameters list
- Previous four changes can be omitted if you switch from non-nullable type to a nullable one, obviously.
A Dart variable is a piece of memory that can contain a data value. Variables are typically used to store information which your Dart program needs to do its job. These variables are case sensitive. To declare a variable, write var directly before the variable.
There are Four types of varibles :
- Top-Level.
- Static.
- Instance.
- Local.
var, const, final, late.
In Numbers there are three types :
- num
- int
- double
int
and double
are, in facts, numbers, meaning that the methods from inside the num
class are completely accessible to both int
and double
types.
To parse a type we can use like this.
var x = int.parse(a);
var y = double.parse(b);
var z = num.parse(c);
// To convert to String
var m = x.toString(a);
var n = x.toString(b);
var o = x.toString(c);
double number = 24.6;
// Nearest and Not Smaller than current value
print(number.ceil());
// Nearest and Not Bigger than current value
print(number.floor());
// Nearest without any other restrictions
print(number.round());
Output :
25
24
25
int truncate()
Returns the integer obtained by discarding any fractional part of this number. Rounds the number towards zero.
// truncate function
var number = 20.3;
print(number.truncate());
// truncate division
var a = 10;
var b = 5;
var c = a ~/ b;
print(c);
Output :
2
Simple concadination
String greetings = 'Happy' ' ' 'Morning';
Output :
Happy Morning
Plus Concadination
var a = 'Happy';
var b = ' Morning';
print(a + b);
Output :
Happy Morning
var paragraph = """Love is beautiful.
It is the mysterious force that binds people to those around them.
It has infinitely many forms, and each of the forms never stays the same for long.
Love is always evolving, and changing intensity.""";
print(paragraph);
Output :
Love is beautiful.
It is the mysterious force that binds people to those around them.
It has infinitely many forms, and each of the forms never stays the same for long.
Love is always evolving, and changing intensity.
var dartProgramming =
"Dart \nDart is an object-oriented programming language.";
print(dartProgramming);
Output :
Dart
Dart is an object-oriented programming language.
// To ignore \n, we can use 'r' infront of the string.
print('\u{1F340}');
Output :
π
var name = 'Ruban';
print(name.hashcode);
Output :
512218410
In boolean, it writtens only true
or false
. And it having an bool
keyword to declare a variable.
bool a = true;
if (a){
print('Success');
}
Output :
Success
A List is simply an ordered group of objects. The dart:core
library provides the List class that enables creation and manipulation of lists.
List<int> list = List.filled(5, 7);
Output :
[7, 7, 7, 7, 7]
// Empty
List<int> list = List.empty();
print(list);
Output:
[]
//Growable
List<int> list = List.empty(growable: true);
list.add(3);
print(list);
Output:
[3]
List<int> list = List.generate(7, (index) => 5);
print(list);
Output :
[5, 5, 5, 5, 5, 5, 5]
Sets in Dart is a special case in List where all the inputs are unique i.e it doesn't contain any repeated input. It can also be interpreted as an unordered array with unique inputs. The set comes in play when we want to store unique values in a single variable without considering the order of the inputs.
var set1 = {1, 2, 3};
var set2 = {2, 3, 4};
// Intersection
var intersect = set1.intersection(set2);
print(intersect);
// Union
var union
// Difference
var difference = set1.difference(set2);
print(difference);
Dart function is a set of codes that together perform a specific task. It is used to break the large code into smaller modules and reuse it when needed. Functions make the program more readable and easy to debug. It improves the modular approach and enhances the code reusability.
void main(List<String> args) {
var name = ['ruban', 'nirmal', 'manoj', 'sanjay', 'teju'].map(applyUpperCase);
print(name);
}
String applyUpperCase(String s) {
return s.toUpperCase();
}
There are four types of parameters :
- Required Positional Parameters.
- Optional Positional Parameters.
- Required Named Parameters.
- Optional Named Parameters
// Standard way
if (a.isEven) {
print('$a is Even Number');
} else {
print('$a is Odd Number');
}
// Shorthand way
a.isEven ? print('$a is Even Number') : print('$a is Odd Number');