0

我遇到了一个图像提供程序错误,我目前正试图修复它(我是 Flutter 的新手)。我得到的错误看起来像这样

../../flutter/packages/flutter/lib/src/painting/image_provider.dart:672:7:错误:需要一个标识符,但得到'/'。/2重投;^

../../flutter/packages/flutter/lib/src/painting/image_provider.dart:672:8:错误:预期为“;” 在这之后。/2重投;^

FAILURE:构建失败并出现异常。

我尝试使用它来修复它,flutter clean但这并不能解决问题。注意我有包含图像的资产目录。

main.dart看起来像

import 'package:flutter/material.dart';

void main() => runApp(MaterialApp(
  home: Home(),
));

class Home extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
          title: Text('my first app'),
          centerTitle: true,
          backgroundColor: Colors.red[600]
      ),
      body: Center(
        child: Image.asset('assets/2.jpg'),
      ),
      floatingActionButton: FloatingActionButton(
        backgroundColor: Colors.red[600],
        child: Text('click'),
      ),
    );
  }
}

pubspec.yaml看起来像这样

name: timeApp
description: A new Flutter project.

https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1

environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter


  cupertino_icons: ^0.1.3

dev_dependencies:
  flutter_test:
    sdk: flutter

flutter:

  # To add assets to your application, add an assets section, like this:
  assets:
    - assets/

4

1 回答 1

0

I also got the same error seems inside flutter\packages\flutter\lib\src\painting\image_provider.dart had a changed date & got corrupted. Just copy back the same from flutter installation zip to resolve issue. More investigation is required what exactly happen

于 2020-11-26T08:06:57.667 回答