Skip to content

Instantly share code, notes, and snippets.

@sorgfal
Created March 24, 2022 14:22
Show Gist options
  • Select an option

  • Save sorgfal/bc1b4e6e8dabaccdd4c5eea973807d9a to your computer and use it in GitHub Desktop.

Select an option

Save sorgfal/bc1b4e6e8dabaccdd4c5eea973807d9a to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
class Item {
Item(this.id, this.name, this.color);
final int id;
final String name;
final Color color;
final int price = 42;
@override
int get hashCode => id;
@override
bool operator ==(Object other) => other is Item && other.id == id;
}
Map<int, Color> colors = {
0: Colors.primaries[0]
};
Color genColor(int id) => Colors.primaries[id % Colors.primaries.length];
void main(){
var a = Item(0,"", genColor(0));
var b = Item(0,"", colors[0]??Colors.red);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment