AppBrewery - BMI Flashcards
theme
define a color palette
cookbook
https://flutter.dev/docs/cookbook for task examples
primary color
The background color for major parts of the app (toolbars, tab bars, etc)
accent color
The foreground color for widgets (knobs, text, overscroll edge effect, etc).
Color constructor
typical hexcode, ARGB, …
color for text in them
textTheme
how to change theme for local widget
wrap widget in Theme widget
ThemeData.dark().copyWith(…)
create a copy of this theme, but edit inner parameters
color of container is shorthand for setting
color of box decoration of container
DRY
Don’t Repeat Yourself
how to make a parameter required
add @required before parameter;
class ExampleClass {
bool isBool;
ExampleClass({@required this.isBool});
immutability
cannot be changed
a stless widget is mutable or immutable?
immutable
const v final
const figured out at compile time; final set only once
final could be set to final string currentTime = DateTime.now();
const could not
Dart class initializer order
- init list 2. constructor
initializer list
init properties (including final ones) before initialization
flatbutton vs inkwell vs gesturerecognizer
flatbutton stylized + opinionated
inkwell has onPressed and visual feedback (ink splash)
gesturerecognizer no visual feedback nor style, many gestures
function type
so even functions are objects and have a type, Function.
void in Dart
denotes absence; return type of a function; can be anything but can’t be used for anything
void onTapMale() { // ... } means what?
onTapMale is a function (of type Function) which returns nothing (void)
enum syntax
enum EnumName { ta, tb, tc, …}
EnumName.ta
syntactic equivalent of void myFunc () {}
Function myFunc = (){}
constants prefix
k
constants dropdown
k …
add a theme to a particular widget
wrap that widget in a theme of its type
.of(), .copyWith()
make this one of a context, then copy it with certain overriding changes