标签: visual-studio-code

Dart 扩展正在自动执行 pub get

Flutter Pub get自动弹出并开始获取包。完成后,它再次开始做同样的事情。

就像我们保存pubspac.yaml一样,vscodedart 插件会自动运行 Flutter pub get。

在此输入图像描述

dart dart-pub visual-studio-code flutter

1
推荐指数
1
解决办法
1348
查看次数

颤动错误:GoogleSignInPlugin.java 使用或覆盖已弃用的 API

我正在开发我的 flutter 应用程序,但在运行项目时,此消息显示在终端中:

    Note: C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\google_sign_in-5.2.3\android\src\main\java\io\flutter\plugins\googlesignin\GoogleSignInPlugin.
    java uses or overrides a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
Run Code Online (Sandbox Code Playgroud)

android dart visual-studio-code flutter

1
推荐指数
1
解决办法
2550
查看次数

“ReadStream”类型的参数不可分配给“string |”类型的参数 Blob' when formData.append(...) 用于文件上传

我正在编写一个扩展,需要通过多部分表单数据上传选定的文件。

我找到了一些片段,例如Cannot POST a multipart/form-data using Fetch TYPESCRIPT,并写了类似的内容:

        window.showOpenDialog({
            canSelectFiles: true,
            canSelectFolders: false,
            canSelectMany: false,
            filters: {
                'image': ['jpg', 'png'],
            },
            title: 'Add Image',
        }).then(async uriList => {
            if (undefined === uriList || uriList.length === 0) {
                return;
            }

            let imageFile = createReadStream(uriList[0].fsPath);

            let formData = new FormData();
            formData.append('file', imageFile); // <- ts(2345) error
        });
Run Code Online (Sandbox Code Playgroud)

然而它抱怨:

Argument of type 'ReadStream' is not assignable to parameter of type 'string | Blob'.
  Type 'ReadStream' is missing the following properties from …
Run Code Online (Sandbox Code Playgroud)

multipartform-data typescript visual-studio-code vscode-extensions

1
推荐指数
1
解决办法
6685
查看次数

重做删除 Visual Studio Code 中的行 -(重做:CTRL + Y)

我的问题:Ctrl + Y删除代码行而不是重做

我一直看到与此问题类似的问题,但没有答案。

keyboard-shortcuts key-bindings undo-redo visual-studio-code

1
推荐指数
1
解决办法
3194
查看次数

LateInitializationError:字段“screenWidth”尚未初始化。颤振异常

我是 flutter 的新手\n我有这个大小的配置文件,我在一个旧项目中使用了它\n现在我再次将它带到另一个项目中,它没有显示任何错误,但当我运行时它给了我一个异常:\n\xe2 \x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90 小部件捕获的异常库 \xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\ xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\ x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\ x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\ xe2\x95\x90\xe2\x95\x90\n构建主体(脏)时抛出以下 LateError:\nLateInitializationError:字段“screenWidth”尚未初始化。

\n
import 'package:flutter/material.dart';\n\n\nclass SizeConfig {\n  static late MediaQueryData _mediaQueryData;\n  static late double screenWidth;\n  static late double screenHeight;\n  static double? defaultSize;\n  static Orientation? orientation;\n  void init(BuildContext context) {\n    _mediaQueryData = MediaQuery.of(context);\n    screenWidth = _mediaQueryData.size.width;\n    screenHeight = _mediaQueryData.size.height;\n    orientation = _mediaQueryData.orientation;\n  }\n}\n// Get the proportionate height as per screen size\ndouble getProportionateScreenHeight(double inputHeight) {\n  double screenHeight = SizeConfig.screenHeight;\n  // 812 is the layout height that designer use\n  return (inputHeight / 812.0) * …
Run Code Online (Sandbox Code Playgroud)

exception dart visual-studio-code flutter

1
推荐指数
1
解决办法
1万
查看次数

vscode g++ 找不到 .cpp 定义文件

我正在尝试使用多个 .cpp 和 .hpp 文件编译 C++ 示例,但 g++ 找不到任何成员函数定义。


主要.cpp:

#include <iostream>
#include "Person.hpp"

int main()
{
    std::cout << "HELL!\n";
    
    Person a{"Jiraya"};
    std::cout << a.getName() << "\n";
    a.setName("Niko");
    a.do_smt();
}
Run Code Online (Sandbox Code Playgroud)

人.hpp:

#pragma once

#include <string>

using std::string;

class Person
{
private:
    string name;

public:
    Person();
    Person(const string &n);
    void do_smt();
    string getName(){return name;}
    void setName(const string& n);
Run Code Online (Sandbox Code Playgroud)

人.cpp:

    #pragma once
    #include <iostream>
    #include "Person.hpp"
    
    Person::Person(const string &n) : name{n}
    {
    }
    
    void Person::setName(const string &n)
    {
        name = n;
    } …
Run Code Online (Sandbox Code Playgroud)

c++ g++ visual-studio-code

1
推荐指数
1
解决办法
1466
查看次数

使用 phpdocblock 定义 php 中方法/函数的通用返回

有没有一种方法可以指定函数将返回特定类型的对象,其中类型是参数之一的字符串?

例如

/**
 * @return object<$class>
 */
public function create(string $class): object {
 ... some factory stuff
}

Run Code Online (Sandbox Code Playgroud)

这样 vscode 或 phpstorm 就会知道当我这样做时

$myvar = X::create('MyClass');
Run Code Online (Sandbox Code Playgroud)

$myvar 将是 MyClass 类型,我将拥有适当的智能感知/自动完成功能?

php visual-studio-code phpstan psalm-php

1
推荐指数
1
解决办法
1706
查看次数

如何在console.log中换行

我发现自己经常想用console.log(...). 例如,如果我有以下代码:

let myVar = "Hello";
myVar.slice(1,3);|            // '|' means where the cursor is after typing in the last line
Run Code Online (Sandbox Code Playgroud)

从那里我想将该行包装在 a 中,console.log这样它就变成:

let myVar = "Hello";
console.log(myVar.slice(1,3));
Run Code Online (Sandbox Code Playgroud)

我可以在 VS Code 中创建一个快捷方式来执行此操作吗?我有一个扩展应该可以做到这一点,但 80% 的情况下它会出错(例如将 放在 the)后面;,所以我只想执行一个总是正确的快捷命令,而不必安装扩展程序。我该怎么做?

javascript visual-studio-code vscode-snippets

1
推荐指数
1
解决办法
979
查看次数

有没有办法在 vscode 资源管理器侧边栏中突出显示我当前正在处理的文件?

我的根文件夹中有很多文件,我希望能够轻松地确定当前文件在 VScode Explorer 侧栏中的位置。

“文件:在侧栏中显示活动文件”命令几乎就是我所需要的:它打开资源管理器侧栏并用蓝色框突出显示当前根文件夹。然而,整个根文件夹被突出显示,而不是特定的文件,所以我仍然必须在该树中的所有其他子目录和文件中寻找它。

是否有一个或一组命令可以用来实现此目的?或者,是否有一个我可以更改的设置,使活动文件始终在侧边栏中突出显示?我只是想要某种指示器来准确查看我的活动文件在树中的位置。

visual-studio-code

1
推荐指数
1
解决办法
1534
查看次数

VS Code Flutter代码保存文件或重启编辑器后自动收缩为一行

我喜欢在每个子组件及其组件的单独行中进行编程,在遇到一些问题后,我最近从 Android Studio 迁移到 VS Code,但我注意到在 VS Code 中,保存文件 (CTRL+S) 或重新启动 IDE,它会自动将代码缩小到一行,这非常令人沮丧,我该如何解决这个问题?

保存前

保存后

dart visual-studio-code flutter

1
推荐指数
1
解决办法
3546
查看次数