我在flutter中导入包时出错

hjzp0vay  于 2023-04-22  发布在  Flutter
关注(0)|答案(2)|浏览(302)

温馨提示:
(抱歉,英语不是我的母语)
(I'm new in flutter)
我在我的flutter项目中有很多错误。我认为这是因为包。当我写:import 'package:flutter/material.dart';,android studio在它下面画了一条红线,这意味着错误,当我在导入包上按住鼠标指针时,它说:Target of URI doesn't exist: 'package:flutter/material.dart'我想这就是为什么所有的错误。我如何修复它?
我的错误:

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)

你能帮帮我吗?我的工作耽搁了几天😭

mepcadol

mepcadol1#

很可能Flutter项目使用的引用出现了问题。您可以运行flutter cleanflutter pub cache repair来帮助重建项目中使用的引用,然后运行flutter pub get来下载配置的插件。

nmpmafwu

nmpmafwu2#

我也遇到了同样的问题,我删除了Flutter并重新安装了它。问题消失了。

相关问题