Reputation: 29
Tips:
(Sorry for mistakes. English isn't my native language)
(I'm new in flutter)
I have many errors in my flutter project. I think that's because of packages. when I write: import 'package:flutter/material.dart';
, android studio draw a red line under it that means error and when I hold down the mouse pointer on import package, It says: Target of URI doesn't exist: 'package:flutter/material.dart'
I think that's why all of the error. How can I fix it?
My errors:
error: Target of URI doesn't exist: 'package:flutter/material.dart'. (uri_does_not_exist at [untitled6] bin\main.dart:1)
error: The function 'runApp' isn't defined. (undefined_function at [untitled6] bin\main.dart:3)
error: Classes can only extend other classes. (extends_non_class at [untitled6] bin\main.dart:5)
error: Undefined class 'Widget'. (undefined_class at [untitled6] bin\main.dart:8)
error: Undefined class 'BuildContext'. (undefined_class at [untitled6] bin\main.dart:8)
error: The method 'MaterialApp' isn't defined for the type 'MyApp'. (undefined_method at [untitled6] bin\main.dart:9)
error: Classes can only extend other classes. (extends_non_class at [untitled6] bin\main.dart:16)
error: Undefined class 'Widget'. (undefined_class at [untitled6] bin\main.dart:19)
error: Undefined class 'BuildContext'. (undefined_class at [untitled6] bin\main.dart:19)
error: The method 'Material' isn't defined for the type 'MyScaffold'. (undefined_method at [untitled6] bin\main.dart:20)
error: The method 'Column' isn't defined for the type 'MyScaffold'. (undefined_method at [untitled6] bin\main.dart:21)
error: The name 'Widget' isn't a type so it can't be used as a type argument. (non_type_as_type_argument at [untitled6] bin\main.dart:22)
error: The name 'Row' isn't a class. (creation_with_non_type at [untitled6] bin\main.dart:23)
error: The name 'IconButton' isn't a class. (creation_with_non_type at [untitled6] bin\main.dart:24)
error: The method 'Icon' isn't defined for the type 'MyScaffold'. (undefined_method at [untitled6] bin\main.dart:25)
error: Undefined name 'Icons'. (undefined_identifier at [untitled6] bin\main.dart:25)
error: The name 'Text' isn't a class. (creation_with_non_type at [untitled6] bin\main.dart:29)
error: The name 'IconButton' isn't a class. (creation_with_non_type at [untitled6] bin\main.dart:30)
error: The method 'Icon' isn't defined for the type 'MyScaffold'. (undefined_method at [untitled6] bin\main.dart:32)
error: Undefined name 'Icons'. (undefined_identifier at [untitled6] bin\main.dart:32)
error: Expected to find ')'. (expected_token at [untitled6] bin\main.dart:37)
error: Expected to find ']'. (expected_token at [untitled6] bin\main.dart:38)
error: Expected to find ')'. (expected_token at [untitled6] bin\main.dart:38)
error: Expected to find ')'. (expected_token at [untitled6] bin\main.dart:39)
info: The method doesn't override an inherited method. (override_on_non_overriding_member at [untitled6] bin\main.dart:8)
info: Unnecessary new keyword. (unnecessary_new at [untitled6] bin\main.dart:11)
info: The method doesn't override an inherited method. (override_on_non_overriding_member at [untitled6] bin\main.dart:19)
info: Unnecessary new keyword. (unnecessary_new at [untitled6] bin\main.dart:23)
info: Unnecessary new keyword. (unnecessary_new at [untitled6] bin\main.dart:24)
info: Unnecessary new keyword. (unnecessary_new at [untitled6] bin\main.dart:29)
info: Unnecessary new keyword. (unnecessary_new at [untitled6] bin\main.dart:30)
Could you please help me? My work has been delayed for a few daysðŸ˜
Upvotes: 2
Views: 22872
Reputation: 583
try this steps:
> flutter clean
> flutter pub get
> flutter pub upgrade
Upvotes: 4
Reputation: 804
I had the same issue, I removed Flutter and reinstalled it. the issue is gone.
Upvotes: 1
Reputation: 10453
It's likely that something is messed up in the references that the Flutter project uses. You can run either flutter clean
or flutter pub cache repair
to help rebuild the references used in the project, then run flutter pub get
to download the configured plugins.
Upvotes: 2