error: The argument type 'String' can't be assigned to the parameter type 'Uri'. usingJsonPlaceHolder

error: The argument type 'String' can't be assigned to the parameter type 'Uri'. usingJsonPlaceHolder

error image
我正在尝试 运行 这段代码但出现错误,有人可以帮忙吗?我尝试制作字符串,但仍然出现相同的错误。

错误:无法将参数类型 'String' 分配给参数类型 'Uri'。 (argument_type_not_assignable 在 [world_time] lib\pages\loading.dart:17)enter image description here

import 'package:flutter/material.dart';
import 'package:http/http.dart';
import 'dart:convert';
import 'dart:core';

class Loading extends StatefulWidget {
  @override
  _LoadingState createState() => _LoadingState();
}

class _LoadingState extends State<Loading> {


  void getData() async {
    Response response = await get(
        'https://jsonplaceholder.typicode.com/todos/1');
    print(response.body);
  }

  @override
  void initState() {
    super.initState();
    getData();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Text('loading screen'),
    );
  }?
}

你可以用这个解决问题:

Uri.parse('https://jsonplaceholder.typicode.com/todos/1')

get(Uri.parse('https://jsonplaceholder.typicode.com/todos/1'));

get(Uri.https('jsonplaceholder.typicode.com', '/todos/1'));