diff --git a/src/docs/cookbook/networking/fetch-data.md b/src/docs/cookbook/networking/fetch-data.md index d89aa2af6c..d2d153f0f1 100644 --- a/src/docs/cookbook/networking/fetch-data.md +++ b/src/docs/cookbook/networking/fetch-data.md @@ -59,7 +59,7 @@ This recipe covers how to fetch a sample album from the ```dart Future fetchAlbum() { - return http.get('https://jsonplaceholder.typicode.com/albums/1'); + return http.get(Uri.https('jsonplaceholder.typicode.com','albums/1')); } ``` @@ -242,7 +242,7 @@ import 'package:http/http.dart' as http; Future fetchAlbum() async { final response = - await http.get('https://jsonplaceholder.typicode.com/albums/1'); + await http.get(Uri.https('jsonplaceholder.typicode.com', 'albums/1'); if (response.statusCode == 200) { // If the server did return a 200 OK response, diff --git a/src/docs/cookbook/networking/send-data.md b/src/docs/cookbook/networking/send-data.md index f806b7f0bf..05150745e5 100644 --- a/src/docs/cookbook/networking/send-data.md +++ b/src/docs/cookbook/networking/send-data.md @@ -56,7 +56,7 @@ by sending an album title to the ```dart Future createAlbum(String title) { return http.post( - 'https://jsonplaceholder.typicode.com/albums', + Uri.https('jsonplaceholder.typicode.com','albums'), headers: { 'Content-Type': 'application/json; charset=UTF-8', }, @@ -132,8 +132,8 @@ function to return a `Future`: ```dart Future createAlbum(String title) async { - final http.Response response = await http.post( - 'https://jsonplaceholder.typicode.com/albums', + final response = await http.post( + Uri.https('jsonplaceholder.typicode.com','albums'), headers: { 'Content-Type': 'application/json; charset=UTF-8', }, @@ -242,8 +242,8 @@ import 'package:flutter/material.dart'; import 'package:http/http.dart' as http; Future createAlbum(String title) async { - final http.Response response = await http.post( - 'https://jsonplaceholder.typicode.com/albums', + final response = await http.post( + Uri.https('jsonplaceholder.typicode.com','albums'), headers: { 'Content-Type': 'application/json; charset=UTF-8', },