ImageProvider bug - Flutter

4.7k views Asked by At

I'm encountering an Image provider bug that I'm currently stuck trying to fix it(I'm new to Flutter). The error I'm getting looks like this

../../flutter/packages/flutter/lib/src/painting/image_provider.dart:672:7: Error: Expected an identifier, but got '/'. /2rethrow; ^

../../flutter/packages/flutter/lib/src/painting/image_provider.dart:672:8: Error: Expected ';' after this. /2rethrow; ^

FAILURE: Build failed with an exception.

I have tried fixing it using flutter clean but that does not resolve the problem. NB I have assets directory that contains the images.

main.dart looks like

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 looks like this

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/

1

There are 1 answers

0
Shankar Krishnamoorthy On

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