我想更改未聚焦的“文本”字段图标的颜色。
通过原色,我可以像第二个文本字段一样更改焦点图标的颜色,我想更改第一个(未单击的颜色)。
我想在整个应用程序中进行更改,因此我在主MaterialApp中使用ThemeData
例如:我希望未聚焦的文本字段图标颜色为紫色,而聚焦的为红色。
答案 0 :(得分:1)
使用var divide = function(dividend, divisor) {
var returnValue = "";
var remainder = 0;
var currentDividend = 0,
currentQuotient;
dividend.split("").forEach(function(digit, index) {
// use classical digit by digit division
if (currentDividend !== 0) {
currentDividend = currentDividend * 10;
}
currentDividend += parseInt(digit);
if (currentDividend >= divisor) {
currentQuotient = Math.floor(currentDividend / divisor);
currentDividend -= currentQuotient * divisor;
returnValue += currentQuotient.toString();
} else if (returnValue.length > 0) {
returnValue += "0";
}
if (index === dividend.length - 1) {
remainder = currentDividend;
}
});
return {
quotient: returnValue.length === 0 ? "0" : returnValue,
remainder: remainder
};
};
var convertToIPv6 = function(input, base) {
base = base || 10;
var blocks = [];
var blockSize = Math.pow(2, 16); // 16 bit per block
while (blocks.length < 8) {
var divisionResult = divide(input, blockSize);
// The remainder is the block value
blocks.unshift(divisionResult.remainder.toString(base));
// The quotient will be used as dividend for the next block
input = divisionResult.quotient;
}
return blocks.join(":");
};
// Examples
["63802943797675961899382738893456539648",
"16894619001915479834806084984789761616",
"734987203501750431791304671034703170303"
].forEach(function(input) {
console.log("Input:", input);
console.log("IP address (decimal):", convertToIPv6(input));
console.log("IP address (hex):", convertToIPv6(input, 16));
});
确定FocusNode
何时未聚焦,然后将所需的颜色分配给TextField
中的Icon()
,并在聚焦时显示默认主题颜色:
prefixicon