Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 颤振-从列表问题中删除项目_Flutter - Fatal编程技术网

Flutter 颤振-从列表问题中删除项目

Flutter 颤振-从列表问题中删除项目,flutter,Flutter,我正在尝试从已按下的列表中删除项目 小部件项如下所示 Flexible( flex: 1, fit: FlexFit.tight, child: IconButton( iconSize: 16.0, color: Colors.green[800], icon: Icon(Icons.delete), onPressed: () => _deleteMaltFromList(gram[index],colors[index],maltname[

我正在尝试从已按下的列表中删除项目

小部件项如下所示


Flexible(
   flex: 1,
   fit: FlexFit.tight,
   child: IconButton(
   iconSize: 16.0,
   color: Colors.green[800],
   icon: Icon(Icons.delete),
   onPressed: () => _deleteMaltFromList(gram[index],colors[index],maltname[index], index, procedure[index]),
                                                            ),
                                                          ),
空区如下所示(索引和过程具有值):

这会产生以下错误: 类“int”没有实例方法“[]”。 收件人:0 已尝试呼叫:

如果我尝试在下面的小部件中调用remove-我可以正常工作

Flexible(
   flex: 1,
   fit: FlexFit.tight,
   child: IconButton(
   iconSize: 16.0,
   color: Colors.green[800],
   icon: Icon(Icons.delete),

   onPressed: (){
   setState(() {
                                                               
      procedure.remove(procedure[index], index);
             });
             },
),
   ),
                                                                

如果
index
int
,那么
index[index]
就没有意义,因为
int
没有
[]
方法<代码>过程显然有一个
[]
方法,并且对
都成功。删除
[]

如果
index
是一个
int
,那么
索引[index]
就没有意义,因为
int
没有
[]
方法<代码>过程显然有一个
[]
方法,并且对
.remove
[]
都成功。remove()

List.remove()
函数删除列表中第一个出现的指定项。如果从列表中删除指定的值,则此函数返回true

List.remove(Object value) 
− 表示应从列表中删除的项的值。 以下示例显示了如何使用此功能: 代码:

void main() { 
   List l = [1, 2, 3,4,5,6,7,8,9]; 
   print('The value of list before removing the list element ${l}'); 
   bool res = l.remove(1); 
   print('The value of list after removing the list element ${l}'); 
}
The value of list before removing the list element [1, 2, 3, 4, 5, 6, 7, 8, 9] 
The value of list after removing the list element [2, 3, 4, 5, 6, 7, 8, 9] 
输出:

void main() { 
   List l = [1, 2, 3,4,5,6,7,8,9]; 
   print('The value of list before removing the list element ${l}'); 
   bool res = l.remove(1); 
   print('The value of list after removing the list element ${l}'); 
}
The value of list before removing the list element [1, 2, 3, 4, 5, 6, 7, 8, 9] 
The value of list after removing the list element [2, 3, 4, 5, 6, 7, 8, 9] 
您可以了解有关列表的更多信息。删除()

List.remove()
函数删除列表中第一个出现的指定项。如果从列表中删除指定的值,则此函数返回true

List.remove(Object value) 
− 表示应从列表中删除的项的值。 以下示例显示了如何使用此功能: 代码:

void main() { 
   List l = [1, 2, 3,4,5,6,7,8,9]; 
   print('The value of list before removing the list element ${l}'); 
   bool res = l.remove(1); 
   print('The value of list after removing the list element ${l}'); 
}
The value of list before removing the list element [1, 2, 3, 4, 5, 6, 7, 8, 9] 
The value of list after removing the list element [2, 3, 4, 5, 6, 7, 8, 9] 
输出:

void main() { 
   List l = [1, 2, 3,4,5,6,7,8,9]; 
   print('The value of list before removing the list element ${l}'); 
   bool res = l.remove(1); 
   print('The value of list after removing the list element ${l}'); 
}
The value of list before removing the list element [1, 2, 3, 4, 5, 6, 7, 8, 9] 
The value of list after removing the list element [2, 3, 4, 5, 6, 7, 8, 9] 

如果我在void call过程中,您可以了解有关

的更多信息;然后我得到这个错误:类“String”没有实例获取程序“remove”。接受者:“T”啊?“索引和过程具有值”。什么价值观?什么类型?听起来这个过程现在是一个字符串而不是一个列表。谢谢Randal-我没有注意到在void调用之后字符串的位置-非常感谢如果我现在在void调用过程中它可以工作。删除[index];然后我得到这个错误:类“String”没有实例获取程序“remove”。接受者:“T”啊?“索引和过程具有值”。什么价值观?什么类型?听起来这个过程现在是一个字符串而不是一个列表。谢谢Randal-我没有注意到在void调用之后的where字符串-非常感谢它现在可以工作了