Dart & Flutter Flashcards
(42 cards)
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’;
import standard library in D
import ‘dart:«package name»’;
import local file in D
import ‘«path»’;
parse JSON in D
import ‘dart:convert’;
var «parsed json» = json.decode(«raw json»);
access map values in D
«map»[«key»]
import specific element of package in D
import «package» show «element»;
create custom stateless widget in F
import ‘package:flutter/material.dart’;
class «name» extends StatelessWidget {
…
}
create custom stateful widget in F
import ‘package:flutter/material.dart’;
class «name» extends StatefulWidget {
…
}
show image from an URL in F
Image.network(«url»)