Created
March 24, 2022 14:22
-
-
Save sorgfal/bc1b4e6e8dabaccdd4c5eea973807d9a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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