AppBrewery - Xylophone Flashcards
1
Q
how to add dependencies
A
in pubspec.yaml, add under dependencies
2
Q
dependency sytnax
A
`dependencies:
(optional>)
3
Q
stless widget constructor for widget properties
A
class KeyNote extends StatelessWidget { final Color color; final int assetNumber;
const KeyNote({ Key key, this.color, this.assetNumber, }) : super (key: key);
@override Widget build(BuildContext context) { return Padding( padding: const EdgeInsets.only(bottom: 10.0), child: FlatButton( color: color, onPressed: playNote, ), ); }
void playNote () { final player = AudioCache(); player.play('note$assetNumber.wav'); } }
4
Q
named, optional Dart function parameters
A
A parameter wrapped by [ ] is a positional optional parameter. Here is an example:
getHttpUrl(String server, String path, [int port=80]) { // ... } A parameter wrapped by { } is a named optional parameter. foo({@required String name}) {...}
5
Q
on column or row, stretch along main axis for available space
A
expanded wraps children
6
Q
type dart functions?
A
if returning, type function of return; int getMilk() { //… return 1}
7
Q
num dart
A
either int or floating point number type
8
Q
dart fat arrow syntax, equivalent
A
The ` => expr syntax is a shorthand for
{ return expr; } `