Dart Flashcards

1
Q

Dart

synchronous operation

A

A synchronous operation blocks other operations from executing until it completes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Dart

synchronous function

A

A synchronous function only performs synchronous operations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Dart

asynchronous operation

A

Once initiated, an asynchronous operation allows other operations to execute before it completes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Dart

asynchronous function

A

An asynchronous function performs at least one asynchronous operation and can also perform synchronous operations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Dart Async

What is a future

A

A future represents the result of an asynchronous operation, and can have two states: uncompleted or completed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Dart async

Uncompleted

A

Uncompleted is a Dart term referring to the state of a future before it has produced a value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Dart async

What happens when you call an asynchronous function?

A

It returns an uncompleted future. That future is waiting for the function’s asynchronous operation to finish or to throw an error.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Dart async

future vs Future

A

Future: the Dart Future class.
future: an instance of the Dart Future class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Dart async

Completed

A

When the operation completes, producing either a value or throw an Error.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Dart async

If a future doesn’t produce a usable value, what is the type?

A

```dart
Future<void>
~~~</void>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Dart async

The two states of a future.

A

Uncompleted or completed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Use cases when initializing a variable using late can be handy

A

The variable might not be needed, and initializing it is costly.
You’re initializing an instance variable, and its initializer needs access to this.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Use cases for the late keyword

A

Declaring a non-nullable variable that’s initialized after its declaration.
Lazily initializing a variable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Instance variables can be […] but not […]

A

Final, const

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Differentiate Final and const modifiers

A

Although a final object cannot be modified, its fields can be changed. In comparison, a const object and its fields cannot be changed: they’re immutable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Differentiate Final and const modifiers

A

Although a final object cannot be modified, its fields can be changed. In comparison, a const object and its fields cannot be changed: they’re immutable.

17
Q

Can we use type checks and casts, collection-if, spread operators in constants?
Provide an example

A

Yes

const Object i = 3; // Where i is a const Object with an int value…
const list = [i as int]; // Use a typecast.
const map = {if (i is int) i: ‘int’}; // Use is and collection if.
const set = {if (list is List<int>) ...list}; // ...and a spread.</int>

18
Q

Can we use type checks and casts, collection-if, spread operators in constants?
Provide an example

A

Yes

const Object i = 3; // Where i is a const Object with an int value…
const list = [i as int]; // Use a typecast.
const map = {if (i is int) i: ‘int’}; // Use is and collection if.
const set = {if (list is List<int>) ...list}; // ...and a spread.</int>

19
Q

Only constants can hold constant values? Provide an example

A

No

var foo = const [];
final bar = const [];
const baz = []; // Equivalent to const []

20
Q

Provide examples of unary postfix operators.
What is the associativity of them?

A

They don’s have associativity

expr++
expr–
()
[]
?[]
.
?.
!

21
Q

What is created when we use operators?

A

Expressions