「Flutter/キャスト」の版間の差分
提供: 初心者エンジニアの簡易メモ
(ページの作成:「==色と文字列== 参考:https://stackoverflow.com/questions/49835146/how-to-convert-flutter-color-to-string-and-back-to-a-color Color color = new Color(0x12345678);...」) |
(→色と文字列) |
||
| 行1: | 行1: | ||
==色と文字列== | ==色と文字列== | ||
参考:https://stackoverflow.com/questions/49835146/how-to-convert-flutter-color-to-string-and-back-to-a-color | 参考:https://stackoverflow.com/questions/49835146/how-to-convert-flutter-color-to-string-and-back-to-a-color | ||
| − | + | <pre> | |
Color color = new Color(0x12345678); | Color color = new Color(0x12345678); | ||
String colorString = color.toString(); // Color(0x12345678) | String colorString = color.toString(); // Color(0x12345678) | ||
| 行7: | 行7: | ||
int value = int.parse(valueString, radix: 16); | int value = int.parse(valueString, radix: 16); | ||
Color otherColor = new Color(value); | Color otherColor = new Color(value); | ||
| + | </pre> | ||
2019年11月14日 (木) 00:41時点における版
色と文字列
Color color = new Color(0x12345678);
String colorString = color.toString(); // Color(0x12345678)
String valueString = colorString.split('(0x')[1].split(')')[0]; // 12345678
int value = int.parse(valueString, radix: 16);
Color otherColor = new Color(value);
