首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >错误:在此之前应为'{‘。@override

错误:在此之前应为'{‘。@override
EN

Stack Overflow用户
提问于 2021-02-07 02:00:57
回答 2查看 670关注 0票数 0

我在flutter代码中得到了一个我不理解的错误。

这是我的代码:

代码语言:javascript
运行
复制
import 'package:flutter/material.dart';


class ReusableScreen extends StatelessWidget{
  final List <String> dirs=['11', '12', '13', '14', '21', '22', '23', '24', '31', '32', '33', '34', '41', '42', '43', '44'];
  final String jour;
  final String heure;

  ReusableScreen({
    @required this.jour,
    @required this.heure,
})

  @override
  Widget build(BuildContext context) {
    return ListView(
      scrollDirection: Axis.horizontal,
      children: [for (var temp in dirs) AssetImage('assets/'+this.jour+"/"+this.heure+"/"+this.dirs[temp])],
    );
  }

}

这是完整的错误消息:

代码语言:javascript
运行
复制
lib/wid.dart:14:3: Error: Expected '{' before this.
  @override
  ^
lib/wid.dart:18:101: Error: A value of type 'String' can't be assigned to a variable of type 'int'.
      children: [for (var temp in dirs) AssetImage('assets/'+this.jour+"/"+this.heure+"/"+this.dirs[temp])],
                                                                                                    ^
lib/wid.dart:18:41: Error: A value of type 'AssetImage' can't be assigned to a variable of type 'Widget'.
 - 'AssetImage' is from 'package:flutter/src/painting/image_resolution.dart' ('/C:/flutter/packages/flutter/lib/src/painting/image_resolution.dart').
 - 'Widget' is from 'package:flutter/src/widgets/framework.dart' ('/C:/flutter/packages/flutter/lib/src/widgets/framework.dart').
      children: [for (var temp in dirs) AssetImage('assets/'+this.jour+"/"+this.heure+"/"+this.dirs[temp])],

你能帮我解决这个问题吗?

EN

Stack Overflow用户

发布于 2021-02-07 02:11:47

构造函数后面缺少一个分号

代码语言:javascript
运行
复制
ReusableScreen({
    @required this.jour,
    @required this.heure,
});
票数 3
EN
查看全部 2 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66080166

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档