AppBrewery - Dicee Flashcards

1
Q

Expanded widget

A

A widget that expands a child of a Row, Column, or Flex so that the child fills the available space.

Using an Expanded widget makes a child of a Row, Column, or Flex expand to fill the available space along the main axis (e.g., horizontally for a Row or vertically for a Column). If multiple children are expanded, the available space is divided among them according to the flex factor.

An Expanded widget must be a descendant of a Row, Column, or Flex, and the path from the Expanded widget to its enclosing Row, Column, or Flex must contain only StatelessWidgets or StatefulWidgets (not other kinds of widgets, like RenderObjectWidgets).

similar to flex; set weight with flex: 2, defaults to flex: 1

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

Image shorthands

A

new Image.asset, for obtaining an image from an AssetBundle using a key.
new Image.network, for obtaining an image from a URL.
new Image.file, for obtaining an image from a File.
new Image.memory, for obtaining an image from a Uint8List.

`Image.asset(‘’)

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

FlatButton()

A

A material design “flat button”.

A flat button is a text label displayed on a (zero elevation) Material widget that reacts to touches by filling with color.

requires onPressed
child can be anything (?)

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

Dart (){ // … }

A

anonymous function

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

Dart string interpolation

A

‘ashijf $<var> oaisjf'</var>

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

put updating vars inside…

and declaration of vars…

A

build, captured by hot reload

outside build, but property of widget

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

Dart dynamic data type

A

Dart is static, but the dynamic data type specifies any type

Although Dart is strongly typed, type annotations are optional because Dart can infer types. In the code above, number is inferred to be of type int. When you want to explicitly say that no type is expected, use the special type dynamic.

var a; a = 123; a = 'ok'; // works, because a is dynamic; type not specified on declaration line.

also:

dynamic a = 123;
a = ‘ok’;

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

Object vs Dynamic

A

Some operations work with any possible object. For example, a log() method could take any object and call toString() on it. Two types in Dart permit all values: Object and dynamic. However, they convey different things. If you simply want to state that you allow all objects, use Object, as you would in Java or C#.

Using dynamic sends a more complex signal. It may mean that Dart’s type system isn’t sophisticated enough to represent the set of types that are allowed, or that the values are coming from interop or otherwise outside of the purview of the static type system, or that you explicitly want runtime dynamism at that point in the program.

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

use dynamic?

A

generally, no. Keep type static safety; avoid var and dynamic

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

shortcut for StatefulWidget

A

stful

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

parts of StatefulWidget

A

StatefulWidget & StatefulWidgetState

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

similar parts between stful and stless widgets

A

the State and the stless widget; both have build

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

for stateful widget, where + how to set state?

A

call setState inside State;

setState triggers rebuild

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

where to declare state?

A

inside State, outside build.

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

setState

A

Notify the framework that the internal state of this object has changed.

Whenever you change the internal state of a State object, make the change in a function that you pass to setState:

Calling setState notifies the framework that the internal state of this object has changed in a way that might impact the user interface in this subtree, which causes the framework to schedule a build for this State object.

When called, app goes thru widget, finds places this state is used, and updates there.

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

put MaterialApp inside or outside a widget…

A

in the build of a widget, so that properties there can be hot reloaded