import 'package:flutter/material.dart';
class ButtonsDemo {
void setState(VoidCallback callback) { }
BuildContext context;
void buttons() {
RaisedButton(
child: const Text('BUTTON TITLE'),
onPressed: () {
},
);
const RaisedButton(
child: Text('BUTTON TITLE'),
onPressed: null,
);
RaisedButton.icon(
icon: const Icon(Icons.add, size: 18.0),
label: const Text('BUTTON TITLE'),
onPressed: () {
},
);
OutlineButton(
child: const Text('BUTTON TITLE'),
onPressed: () {
},
);
const OutlineButton(
child: Text('BUTTON TITLE'),
onPressed: null,
);
OutlineButton.icon(
icon: const Icon(Icons.add, size: 18.0),
label: const Text('BUTTON TITLE'),
onPressed: () {
},
);
FlatButton(
child: const Text('BUTTON TITLE'),
onPressed: () {
},
);
const FlatButton(
child: Text('BUTTON TITLE'),
onPressed: null,
);
String dropdownValue;
DropdownButton<String>(
value: dropdownValue,
onChanged: (String newValue) {
setState(() {
if (newValue != null)
dropdownValue = newValue;
});
},
items: <String>['One', 'Two', 'Free', 'Four']
.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value));
})
.toList(),
);
bool value;
IconButton(
icon: const Icon(Icons.thumb_up),
onPressed: () {
setState(() => value = !value);
},
color: value ? Theme.of(context).primaryColor : null,
);
Scaffold(
appBar: AppBar(
title: const Text('Demo'),
),
floatingActionButton: const FloatingActionButton(
child: Icon(Icons.add),
onPressed: null,
),
);
}
}
class SelectionControls {
void setState(VoidCallback callback) { }
void selectionControls() {
bool checkboxValue = false;
Checkbox(
value: checkboxValue,
onChanged: (bool value) {
setState(() {
checkboxValue = value;
});
},
);
Checkbox(
tristate: true,
value: checkboxValue,
onChanged: (bool value) {
setState(() {
checkboxValue = value;
});
},
);
const Checkbox(value: false, onChanged: null);
int radioValue = 0;
void handleRadioValueChanged(int value) {
setState(() {
radioValue = value;
});
}
Row(
children: <Widget>[
Radio<int>(
value: 0,
groupValue: radioValue,
onChanged: handleRadioValueChanged,
),
Radio<int>(
value: 1,
groupValue: radioValue,
onChanged: handleRadioValueChanged,
),
Radio<int>(
value: 2,
groupValue: radioValue,
onChanged: handleRadioValueChanged,
),
],
);
const Radio<int>(
value: 0,
groupValue: 0,
onChanged: null,
);
bool switchValue = false;
Switch(
value: switchValue,
onChanged: (bool value) {
setState(() {
switchValue = value;
}
);
});
const Switch(value: false, onChanged: null);
}
}
class GridLists {
void gridlists() {
GridView.count(
crossAxisCount: 3,
childAspectRatio: 1.0,
padding: const EdgeInsets.all(4.0),
mainAxisSpacing: 4.0,
crossAxisSpacing: 4.0,
children: <String>[
'https://example.com/image-0.jpg',
'https://example.com/image-1.jpg',
'https://example.com/image-2.jpg',
'...',
'https://example.com/image-n.jpg',
].map<Widget>((String url) {
return GridTile(
footer: GridTileBar(
title: Text(url),
),
child: Image.network(url, fit: BoxFit.cover),
);
}).toList(),
);
}
}
class AnimatedImage {
void animatedImage() {
Image.network('https://example.com/animated-image.gif');
}
}