Java integer color to flutter color and back. Java uses signed 32 bit integers. Expanding on the code block they posted, we can create a full example which gives us what we need:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | import 'dart:math'; int chopToJavaInt (int result) { while (result > pow(2, 31)) { result = result - pow(2, 32); } return result; } int javaIntColor(int r, int g, int b) { var x = (g << 24) | (r << 16) | (g << 8) | b; return chopToJavaInt(x); } void main () { print(javaIntColor(154, 255, 147)); //-6619245 } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.