Dart Flashcards

1
Q

Dart overview

A
  • Object oriented language
  • Statically Typed
  • C-Style Syntax
  • Multiple Runtime Env.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Sample method

A
String myName () {
  return 'Stephen';
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Main method

A

void main ( ) { … }

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

Variable declaration

A
var name = myName();
const value = 1000;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Type System

A
  • Every value has a type
  • Every variable has a type reference
  • variables type cannot change
  • Dart can guess type
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Built-in Types

A
  • numbers
  • strings
  • booleans
  • lists (arrays)
  • sets
  • maps
  • runes (Unicode char strings)
  • symbols
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Number types

A
  • int -2^63 to 2^63 - 1
  • double IEEE 754
  • both of them are subtypes of num
var y = 1;
var hex= 0xDEADBEEF;
var y = 1.1;
var exponents = 1.42e5;

double z = 1; // equalst to z=1.0

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

Numbers to String and back

A

int. parse(‘1’);
double. parse(‘1.1’);
1. toString();
3. 14.toStringAsFixed(2);

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

Bitwise Operators

A

&laquo_space;» & |

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

What is a String?

A

UTF-16 unit sequence

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

Create Strings

A
var s1 = 'Single quotes work well for string literals.';
var s2 = "Double quotes work just as well.";
var s3 = 'It\'s easy to escape the string delimiter.';
var s4 = "It's even easier to use the other delimiter.";
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

String expressions

A
  • ${expression}
  • If the expression is an identifier, you can skip the {}
var s = 'string interpolation';
'Dart has $s, which is very handy.'
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

String equality

A

The == operator tests whether two objects are equivalent. Two strings are equivalent if they contain the same sequence of code units.

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

Concat Strings

A

You can concatenate strings using adjacent string literals or the + operator:

var s1 = 'String '
    'concatenation'
    " works even over line breaks.";
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Multi-line string

A

use a triple quote with either single or double quotation marks:

var s1 = ‘’’
You can create
multi-line strings like this one.
‘’’;

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

Raw String

A
You can create a “raw” string by prefixing it with r:
var s = r'In a raw string, not even \n gets special treatment.';