Dart & Flutter Flashcards

(42 cards)

1
Q

embed variable in string in D

A

‘«string» $«variable» «string»’

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

statement in D

A

«statement»;

» always with semicolon

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

entry point of D app

A
void main() {
  ...
}

» main function

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

embed expression in string in D

A

‘«string» ${«expression»} «string»’

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

multiline string in D

A

’’‘«multi line
string»’’’

””“«multi line
string»”””

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

raw string in D

A

r’«raw string»’

» no special character treatment

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

types in D

A
» void
» null
» dynamic
» bool
» int
» double
» String
» List (like Array in JS)
» Set (like unordered Array)
» Map (like Object in JS)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

comment in D

A

// «single line comment»

/* «multi line
comment» */

/// «single line documentation comment»

/** «multi line
documentation comment» **/
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

declare variable in D

A

var «name»;
» reassignable

final «name»;
» runtime constant
» mutable
» not reassignable

const «name»;
» compile time constant
» not mutable
» not reassignable
» freezes data structures like Map and List
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
declare class with fields in D
(f.ex. person)
A
class Person {
  String firstName, lastName, fullName;
  int age = 0;
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

shuffle order of list in D

A

«list».shuffle();

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

filter elements of list in D

A

«list».where((«element») => «check»);

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

add element to list in D

A

«list».add(«element»);

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

get part of list in D

A

«list».sublist(«start», «_end before»);

» returns a list object
» returns rest of original list if «_end before» is omitted

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

remove specific elements from list in D

A

«list».removeWhere((«element») => «check»);

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

import third party package in D

A

import ‘package:«package name»/«file name».dart’;

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

import standard library in D

A

import ‘dart:«package name»’;

18
Q

import local file in D

A

import ‘«path»’;

19
Q

parse JSON in D

A

import ‘dart:convert’;

var «parsed json» = json.decode(«raw json»);

20
Q

access map values in D

A

«map»[«key»]

21
Q

import specific element of package in D

A

import «package» show «element»;

22
Q

create custom stateless widget in F

A

import ‘package:flutter/material.dart’;

class «name» extends StatelessWidget {

}

23
Q

create custom stateful widget in F

A

import ‘package:flutter/material.dart’;

class «name» extends StatefulWidget {

}

24
Q

show image from an URL in F

A

Image.network(«url»)

25
set padding/margin widget in F
EdgeInsets .only(_left: «val», _top: «val», _right: «val», _bottom: «val») .symmetric(_vertical: «val», _horizontal: «val») .fromLTRB(«val», «val», «val», «val») .all(«val») //.fromWindowPadding(«padding», «devicePixelRatio value») » val: double
26
set border widget in F
Border(_top: «bs», _right: «bs», _bottom: «bs», _left: «bs») Border.symmetric(_vertical: «bs», _horizontal: «bs») Border.fromBorderSide(«bs») Border.all(_color: «color», _width: «width», _style: BorderStyle.«style») » bs: BorderSide » style: solid or none
27
set color widget by color code in F
Color(0̸xAARRGGBB) Color.fromARGB(«alpha», «red», «green», «blue») Color.fromRGBO(«red», «green», «blue», «opacity») » 0̸x value must be 8 digits » opacity: double
28
use mixin in D
import '«path to mixin»'; class «name» extends «class» with «mixin» { ... } » mixin: another _abstract class
29
``` declare abstract class in D (like interface in TS) ```
``` abstract class «name» { «_field»... «_constructor»... «_method»... «_abstract method»(«_type» «_prop»); } ``` » cannot be instantiated » abstract methods have to be implemented on »extends«
30
implement class as an interface in D
class «name» implements «class» { ... } » inherits types only
31
set default value for case that variable will be null in D
«variable to check» ?? «default value»
32
arrow function in D
(«_type» «param», «_type2» «_param2») => «value» --------------- («_type» «param», «_type2» «_param2») => { ... return «value»; } » params always in brackets
33
set border on container widget in F
``` Container( decoration: BoxDecoration( border: «Border» ), ), ```
34
set border side widget in F
BorderSide(_color: «color», _width: «width», _style: BorderStyle.«style»)) » style: solid or none
35
set border style widget in F
BorderStyle.«style» » style: solid or none
36
set color widget by material enum in F
Colors.«color»_[«intensity»] Colors.«color»_Accent_[«intensity»] » color: transparent, red, blue, grey etc. » intensity: 100-900, default is 500 » accent intensity: 100, 400, 700, default is 200
37
set color widget to black or white in F
Colors.«black|white»«_opacity» » black opacity: 12, 26, 38, 45, 54, 87 » white opacity: 10, 12, 24, 30, 38, 54, 60, 70
38
``` declare class with constructor in D (f.ex. person) ```
``` class Person { String firstName, lastName, fullName; ``` Person(this.firstName, this.lastName) { fullName = '$firstName $lastName'; } }
39
``` declare class with named constructor in D (f.ex. person) ```
``` class Person { String firstName, lastName, fullName; ``` ``` Person.dummy() { firstName = 'Bruce'; lastName = 'Wayne'; fullName = '$firstName $lastName'; } } ```
40
``` declare class with method in D (f.ex. person) ```
``` class Person { String name; ``` Person(this.name); greet(String greeting) { print('$greeting, $name'); } }
41
``` declare class with getter and setter in D (f.ex. person) ```
``` class Person { int birthYear; ``` ``` int get age => DateTime.now().year - birthYear; set age(int value) => birthYear = DateTime.now() - value; } ```
42
inherit from other class in D
class «name» extends «class» { ... } » inherits types and implementations » abstract methods have to be implemented now