Dart & Flutter Flashcards
embed variable in string in D
‘«string» $«variable» «string»’
statement in D
«statement»;
» always with semicolon
entry point of D app
void main() { ... }
» main function
embed expression in string in D
‘«string» ${«expression»} «string»’
multiline string in D
’’‘«multi line
string»’’’
””“«multi line
string»”””
raw string in D
r’«raw string»’
» no special character treatment
types in D
» void » null » dynamic » bool » int » double » String » List (like Array in JS) » Set (like unordered Array) » Map (like Object in JS)
comment in D
// «single line comment»
/* «multi line comment» */
/// «single line documentation comment»
/** «multi line documentation comment» **/
declare variable in D
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
declare class with fields in D (f.ex. person)
class Person { String firstName, lastName, fullName; int age = 0; }
shuffle order of list in D
«list».shuffle();
filter elements of list in D
«list».where((«element») => «check»);
add element to list in D
«list».add(«element»);
get part of list in D
«list».sublist(«start», «_end before»);
» returns a list object
» returns rest of original list if «_end before» is omitted
remove specific elements from list in D
«list».removeWhere((«element») => «check»);
import third party package in D
import ‘package:«package name»/«file name».dart’;