List<String> checkLength(List<String> input) {
if (input.length > 6) {
var tempOutput = input;
while (tempOutput.length > 6) {
var difference = (tempOutput.length/6).round() + 1;
for (int i = 0; i < tempOutput.length - 1; i + difference) {
tempOutput.removeAt(i); //Removing the value from the list
}
}
return tempOutput; //Return Updated list
} else {
return input;
}
}
Run Code Online (Sandbox Code Playgroud)
我试图从临时列表中删除一些东西.为什么不起作用?我没有看到它是如何修复的,在我解决的其他问题中,我使用了类似的方法并且它有效(甚至相同)
请注意我对Dart有点新意,所以请原谅我这样的问题,但我无法弄清楚解决方案.
查找Dart Link中提供的代码
在 React 项目中,最终用户可以使用工具生成 CSS。
我找到了如何生成 JS 对象并将其传递给style={}属性,但我想将生成的 JS 对象转换为 CSS 字符串,以便我可以保存它并在其他地方使用它。
我想将 JSObject 转换为 CSS:
JSObject [示例 - 输入]
JSObject: {
lineHeight: 1,
fontSize: 15,
padding: 0,
margin: 0,
msBoxShadow: '0 0 1px 1px #000',
MozBoxShadow: '0 0 1px 1px #000',
OBoxShadow: '0 0 1px 1px #000',
WebkitBoxShadow: '0 0 1px 1px #000',
boxShadow: '0 0 1px 1px #000'
}
Run Code Online (Sandbox Code Playgroud)
预期的 CSS [示例 - 输出]
.cssClass{
line-height: 1;
font-size: 15px;
padding: 0px;
margin: 0px;
box-shadow: rgb(0, 0, 0) …Run Code Online (Sandbox Code Playgroud)