简体   繁体   English

在 flutter 中添加依赖项时出错

[英]Error with adding dependencies in flutter

I ran into such a problem that when adding the get: dependency to flutter, nothing happens.我遇到了这样一个问题,当将 get: 依赖项添加到 flutter 时,没有任何反应。 And when importing并且在导入时

import 'pack:get/get.dart';

to the main file, the editor suggests adding this dependency, but the error " Cannot read property " pops up 'replace' of undefined".到主文件,编辑器建议添加此依赖项,但错误“ Cannot read property ”弹出“替换”未定义”。

Someone may have encountered a similar problem, how to fix it?可能有人遇到过类似的问题,怎么解决?

    name: flutter_application_1
    description: A new Flutter project.
    
    
    publish_to: 'none' # Remove this line if you wish to publish to pub.dev
    
    
    version: 1.0.0+1
    
    environment:
      sdk: ">=2.12.0 <3.0.0"
    
    
    dependency_overrides:
      flutter_web:
        git:
          url: https://github.com/flutter/flutter_web
          path: packages/flutter_web
      flutter_web_ui:
        git:
          url: https://github.com/flutter/flutter_web
          path: packages/flutter_web_ui
    dependencies:
      cupertino_icons: ^1.0.2
      flutter:
        sdk: flutter
    
    dev_dependencies:
    
      
      flutter_lints: ^1.0.0
      flutter_test:
        sdk: flutter
    
    
    flutter:
    
    
      uses-material-design: true

I got the same problem.我遇到了同样的问题。

I guess it is because I have two version on my MacOS system, one is 1.60 and the other is 1.62, and when ver1.62 upgrade to 1.63 this issue happened.我猜是因为我的 MacOS 系统有两个版本,一个是 1.60,另一个是 1.62,当 ver1.62 升级到 1.63 时出现了这个问题。

Fix:使固定:

Uninstall both version and install ver1.60 ( https://code.visualstudio.com/updates/v1_60 ), the issue gone, then upgrade ver1.60 to ver1.63, and it gone too...卸载两个版本并安装ver1.60( https://code.visualstudio.com/updates/v1_60 ),问题消失了,然后将ver1.60升级到ver1.63,它也消失了......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM