Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.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_Dart - Fatal编程技术网

Flutter 颤振型';字符串';不是类型为';列表<;字符串>';属于';功能结果';

Flutter 颤振型';字符串';不是类型为';列表<;字符串>';属于';功能结果';,flutter,dart,Flutter,Dart,我正在尝试显示鞋码列表: Text( widget.shoe.size[i].toString(), style: TextStyle(fontSize: 18), ), class Shoe {final String name; final List<String> size; final String imageurl; Shoe(this.name, this.size, this.imageurl); } List<Shoe> shoes =

我正在尝试显示鞋码列表:

Text( widget.shoe.size[i].toString(), style: TextStyle(fontSize: 18), ),
class Shoe {final String name;
  final List<String> size;
  final String imageurl;

  Shoe(this.name, this.size, this.imageurl);
}


List<Shoe> shoes = [
  Shoe('Teebon M', ['38', '39', '40', '41', '42'],
      'https://rukminim1.flixcart.com/image/800/960/ke8uv0w0-0/shoe/i/g/f/cm4701-8-adidas-silvmt-cblack-ftwwht-original-imafuywffvmfxcgr.jpeg'),
  Shoe('Hyperon M,', ['38', '39', '40', '41', '42'],
      'https://rukminim1.flixcart.com/image/800/960/jseyoi80/shoe/n/v/u/ck9515-8-adidas-mysblu-ftwwht-cblack-original-imafdzrzkvud2eyc.jpeg'),
  Shoe('Glarus M', ['38', '39', '40', '41', '42'],
      'https://rukminim1.flixcart.com/image/800/960/kdrpksw0-0/shoe/f/a/k/cm4979-8-adidas-deeblu-silvmt-original-imafuhzgu4yyg6bp.jpeg'),
  Shoe('Pictor M', ['38', '39', '40', '41', '42'],
      'https://rukminim1.flixcart.com/image/800/960/ki96c280-0/shoe/n/r/x/ew2423-6-adidas-dovgry-gresix-stigrn-original-imafy38tfuytnxjk.jpeg'),
];
════════ Exception caught by widgets library ═══════════════════════════════════
The following _TypeError was thrown building Details(dirty, dependencies: [MediaQuery], state: _DetailsState#a0102):
type 'String' is not a subtype of type 'List<String>' of 'function result'
我的鞋型是:

Text( widget.shoe.size[i].toString(), style: TextStyle(fontSize: 18), ),
class Shoe {final String name;
  final List<String> size;
  final String imageurl;

  Shoe(this.name, this.size, this.imageurl);
}


List<Shoe> shoes = [
  Shoe('Teebon M', ['38', '39', '40', '41', '42'],
      'https://rukminim1.flixcart.com/image/800/960/ke8uv0w0-0/shoe/i/g/f/cm4701-8-adidas-silvmt-cblack-ftwwht-original-imafuywffvmfxcgr.jpeg'),
  Shoe('Hyperon M,', ['38', '39', '40', '41', '42'],
      'https://rukminim1.flixcart.com/image/800/960/jseyoi80/shoe/n/v/u/ck9515-8-adidas-mysblu-ftwwht-cblack-original-imafdzrzkvud2eyc.jpeg'),
  Shoe('Glarus M', ['38', '39', '40', '41', '42'],
      'https://rukminim1.flixcart.com/image/800/960/kdrpksw0-0/shoe/f/a/k/cm4979-8-adidas-deeblu-silvmt-original-imafuhzgu4yyg6bp.jpeg'),
  Shoe('Pictor M', ['38', '39', '40', '41', '42'],
      'https://rukminim1.flixcart.com/image/800/960/ki96c280-0/shoe/n/r/x/ew2423-6-adidas-dovgry-gresix-stigrn-original-imafy38tfuytnxjk.jpeg'),
];
════════ Exception caught by widgets library ═══════════════════════════════════
The following _TypeError was thrown building Details(dirty, dependencies: [MediaQuery], state: _DetailsState#a0102):
type 'String' is not a subtype of type 'List<String>' of 'function result'
classshoe{最后的字符串名;
最终列表大小;
最终字符串imageurl;
Shoe(this.name、this.size、this.imageurl);
}
列出鞋子=[
鞋款('Teebon M',['38','39','40','41','42'],
'https://rukminim1.flixcart.com/image/800/960/ke8uv0w0-0/shoe/i/g/f/cm4701-8-adidas-silvmt-cblack-ftwwht-original-imafuywffvmfxcgr.jpeg'),
鞋子('Hyperon M',['38','39','40','41','42'],
'https://rukminim1.flixcart.com/image/800/960/jseyoi80/shoe/n/v/u/ck9515-8-adidas-mysblu-ftwwht-cblack-original-imafdzrzkvud2eyc.jpeg'),
鞋子('Glarus M',[38',39',40',41',42'],
'https://rukminim1.flixcart.com/image/800/960/kdrpksw0-0/shoe/f/a/k/cm4979-8-adidas-deeblu-silvmt-original-imafuhzgu4yyg6bp.jpeg'),
鞋子('Pictor M',[38',39',40',41',42'],
'https://rukminim1.flixcart.com/image/800/960/ki96c280-0/shoe/n/r/x/ew2423-6-adidas-dovgry-gresix-stigrn-original-imafy38tfuytnxjk.jpeg'),
];
但是每次我遇到这个错误:

Text( widget.shoe.size[i].toString(), style: TextStyle(fontSize: 18), ),
class Shoe {final String name;
  final List<String> size;
  final String imageurl;

  Shoe(this.name, this.size, this.imageurl);
}


List<Shoe> shoes = [
  Shoe('Teebon M', ['38', '39', '40', '41', '42'],
      'https://rukminim1.flixcart.com/image/800/960/ke8uv0w0-0/shoe/i/g/f/cm4701-8-adidas-silvmt-cblack-ftwwht-original-imafuywffvmfxcgr.jpeg'),
  Shoe('Hyperon M,', ['38', '39', '40', '41', '42'],
      'https://rukminim1.flixcart.com/image/800/960/jseyoi80/shoe/n/v/u/ck9515-8-adidas-mysblu-ftwwht-cblack-original-imafdzrzkvud2eyc.jpeg'),
  Shoe('Glarus M', ['38', '39', '40', '41', '42'],
      'https://rukminim1.flixcart.com/image/800/960/kdrpksw0-0/shoe/f/a/k/cm4979-8-adidas-deeblu-silvmt-original-imafuhzgu4yyg6bp.jpeg'),
  Shoe('Pictor M', ['38', '39', '40', '41', '42'],
      'https://rukminim1.flixcart.com/image/800/960/ki96c280-0/shoe/n/r/x/ew2423-6-adidas-dovgry-gresix-stigrn-original-imafy38tfuytnxjk.jpeg'),
];
════════ Exception caught by widgets library ═══════════════════════════════════
The following _TypeError was thrown building Details(dirty, dependencies: [MediaQuery], state: _DetailsState#a0102):
type 'String' is not a subtype of type 'List<String>' of 'function result'
════════ widgets库捕获到异常═══════════════════════════════════
生成详细信息时引发了以下_TypeError(脏,依赖项:[MediaQuery],状态:_DetailsState#a0102):
类型“字符串”不是“函数结果”的“列表”类型的子类型

我认为
widget.shoe.size[I]
不包含您认为它包含的值。创建
文本
对象的方式看起来不错。可能尝试调试以查看哪些值
widget
widget.shoe
等必须查看您的问题所在。

不要使用.toString()函数,请按以下方式执行:

Text( '${widget.shoe.size[i]}', style: TextStyle(fontSize: 18), ),

要显示尺寸列表,您可以将所有数字串联在一个
字符串中并显示它

Text(widget.shoe.size.join(',')//逗号分隔的数字

你的模型没问题。.可能问题在于你在哪里使用了
并调用了列表。你能添加代码吗请更新代码最好的方法是编写测试代码,你可以看到问题。你只需删除小部件.shoe.size[i]中的.toString()已经是一个字符串了。非常感谢您的回答,这是我在stackoverflow上发布的第一个问题,没想到会这么快得到答案。非常感谢您的帮助。非常感谢您的帮助。非常感谢您的帮助。非常感谢您的帮助。非常感谢您的回答非常感谢您的帮助