Flutter throwing error when used the get method in the http package


When I am trying to get data from the internet to use it in my app via the get method provided by the flutter http package it throws this error – The argument type ‘String’ can’t be assigned to the parameter type ‘Uri’. This is my code

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

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

class _LoadingState extends State<Loading> {
  void getData() async {

  void initState() {

  Widget build(BuildContext context) {
    return Scaffold(
      body: Text("some text"),


First argument of http package request method is Uri type, So you have to change your code to this:

  void getData() async {
    final requestUrl = Uri.parse("https://jsonplaceholder.typicode.com/todos/1");

Answered By – BeHappy

Answer Checked By – Mildred Charles (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *