Dart Flashcards

(35 cards)

1
Q

What is required for a dart program

A

A main method

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

How should variables be named in Dart

A

Camel Case

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

How do you accomplish string interpolation in Dart

A

$variableName

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

How can you interpolate an expression in Dart?

A

${expression}

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

How do you escape special characters

A

/

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

How do you print a string without having to escape special characters?

A

r”stuff” - raw string

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

What is multi line string syntax?

A

”"”stuff”””

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

How do you do integer division?

A

~/

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

What effect does the prefix and postfix operators have?

A

Prefix (++x) adds and then assigns the value of x, postfix (x++) assigns the value of x and then adds

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

How do you write a hex number?

A

0x(number)

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

How can you print numbers in binary or hex?

A

(string).toRadixString((base))

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

Expressions

A

Hold a value at runtime

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

Statements

A

Do not hold a value at runtime

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

When is var used?

A

To declare variables that can be used more than once

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

When is final used?

A

For read only variables

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

When is const used?

A

For compile time constants

17
Q

When is dynamic used?

A

When you want to be able to change the type of the variable

18
Q

What are the collections in Dart

A

Lists, sets and Maps

19
Q

What’s special about sets?

A

They only hold unique values

20
Q

What are maps like?

21
Q

How can I read a file?

A

final lines = File(inputFile).readAsLinesSync();

22
Q

What does a question mark after a variable mean?

A

It’s nullable

23
Q

What is the if-null operator?

A

??, it assigns whatever is after it if the variable is null

24
Q

What does this do? maybeNull ??= 0

A

Assigns 0 to maybeNull if it’s null

25
How do positional arguments work?
Put the arguments in the method in {} and pass name: value when calling it
26
How can you implement optional positional arguments?
Put them in []
27
What is => for?
Fat arrow notation, for functions that only have one line remove {} and return
28
What is an alias?
A name given to a function type so it can be reused
29
rHow does forEach work?
list.forEach((x) => print(x));
30
What is map for?
Take a collection, perform some transformation on it and return a new collection
31
What does the where method do?
Performs filtering
32
What is the reduce method for?
Combining elements in a collection
33
What is an initializer list in dart?
It assigns variables passed into the constructor to member variables and is started after the constructor with a colon
34
What are getters also known as?
Computed variables
35
What are class variables known as?
Stored variables