We will list down some of the basic things of Flutter which you maybe using but just didn’t care to look into or think about.
- What is dart:core?
The package which is responsible for all the dart functionalities in your code. Why don’t you see it anywhere? Well, it’s imported by default 😛 - What is dart:io?
The standard package for input out operations. It has functions for
a. reading from the standard input(keyboard) stdin.readLineSync()
b. writing to standard out(monitor) stdout.writeLn(“”) - What is string interpolation?
Interpolation basically means finding the unknown given a set of known values. String interpolation is making a string which contains weird characters which get substituted with actual values while making the final string. Okay, maybe an example would clear this.
String name = "Amazing Tod";
print("Hello there $name"); // Hello there Amazing Tod
So you see, the final string had the variable’s value substituted in it. A similar thing can be found in JavaScript using template literals.
4. What is assert() ?
assert is used to do a conditional check. But the main difference from if block is
that it terminates the program as soon as condition is false. So,
assert(0 == 1);
will stop the program execution. This is mainly helpful during debugging.
5. What is Null Aware operator?
Instead of checking for null on a variable, you can use a short cut in dart.
class A
{
int a = 10;
}
void main()
{
var num = A(); int b;
b = num?.a ?? 0; // Assign a to b if num is not null else assign 0
print(b);
}