Skip to content

Instantly share code, notes, and snippets.

@xinthink
Created March 5, 2020 09:43
Show Gist options
  • Save xinthink/19d042dd248f868df4bc7d576684a6e6 to your computer and use it in GitHub Desktop.
Save xinthink/19d042dd248f868df4bc7d576684a6e6 to your computer and use it in GitHub Desktop.
class LinearColorPicker extends StatelessWidget {
Color _currColor(Note note) => note?.color ?? kDefaultNoteColor;
@override
Widget build(BuildContext context) {
Note note = Provider.of<Note>(context);
return SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
children: kNoteColors.map((color) => InkWell(
child: Container(
...
color: color,
child: color == _currColor(note) ? const Icon(Icons.check) : null,
),
onTap: () {
if (color != _currColor(note)) {
note.updateWith(color: color);
}
},
)).toList(),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment