为什么 http.dart 文件在添加依赖项后从导入行重定向时显示为空,而且 http.get(url) 方法未定义

why http.dart file shows empty when redirecting from import line after adding dependency , also http.get(url) method is undfined

我是 flutter 的新手,实际上我在 pubspec.yaml 中添加依赖项 "http: ^0.12.0" 后导入 http.dart 文件,但是一旦我开始导入 http.dart 文件在 main.dart 并重定向到 http.dart 文件,它在那里显示为空 http.get(url) 也无法识别。

这就是我导入 http.dart 文件的方式:-

import 'package:flutter/http/http.dart' as http;

这是我的 pubspec.yaml:-

   ---
cupertino_icons: ^0.1.2
dependencies:
  flutter:
    sdk: flutter
description: "A new Flutter application."
dev_dependencies:
  flutter_test:
    sdk: flutter
environment:
  sdk: ">=2.0.0-dev.68.0 <3.0.0"
flutter:
  uses-material-design: true
name: flutter_app
shared_preferences: ^0.2.0
version: 1.0.0+1

任何帮助将不胜感激,提前致谢!

这就是您应该导入的方式

import 'package:http/http.dart' as http;

你的 pubspec.yaml 是这样的:

dependencies:
  flutter:
    sdk: flutter
  http: any

运行 $flutter upgrade 获取最新的 flutter sdk