The tiny things of Flutter

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.

  1. 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 😛
  2. 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(“”)
  3. 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

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.