Skip to content

Instantly share code, notes, and snippets.

@rxlabz
Last active May 28, 2017 22:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rxlabz/5bd7ea97dc86184f5f1266a3368b672c to your computer and use it in GitHub Desktop.
Save rxlabz/5bd7ea97dc86184f5f1266a3368b672c to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
const kSwatchSize = 36.0;
void main() {
runApp(new MaterialApp(
home: new Scaffold(
body: new Stack(children: [
new Positioned(
left: 200.0,
top: 200.0,
child: new SizedBox(
width: 600.0,
height: 300.0,
child: new GridView.count(
crossAxisCount: 6,
children: _getColorMenuTileItems(),
)),
),
]),
)));
}
List<PopupMenuItem<Color>> _getColorMenuTileItems() {
final colors = Colors.primaries.map((c) => c).toList();
colors.addAll([Colors.black, Colors.grey, Colors.white]);
return colors.map((c) {
return new PopupMenuItem<Color>(
value: c,
child: new GridTile(
child: new Container(
width: kSwatchSize,
height: kSwatchSize,
color: c,
)),
);
}).toList();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment