Skip to content

Commit 88f6fc6

Browse files
authored
Always using package:http for APIs and image loading. (#839)
* Always using `package:http` for APIs and image loading. * Fix changelog notes
1 parent 46a7708 commit 88f6fc6

File tree

6 files changed

+25
-3
lines changed

6 files changed

+25
-3
lines changed

pkgs/cronet_http/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 0.0.4
2+
3+
* Fix a bug where the example would not use the configured `package:http`
4+
`Client` for Books API calls in some circumstances.
5+
* Fix a bug where the images in the example would be loaded using `dart:io`
6+
`HttpClient`.
7+
18
## 0.0.3
29

310
* Fix

pkgs/cronet_http/example/lib/main.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import 'dart:convert';
66
import 'dart:io';
77

8+
import 'package:cached_network_image/cached_network_image.dart';
89
import 'package:cronet_http/cronet_client.dart';
910
import 'package:flutter/material.dart';
1011
import 'package:http/http.dart';
@@ -14,7 +15,6 @@ import 'book.dart';
1415
void main() {
1516
var clientFactory = Client.new; // Constructs the default client.
1617
if (Platform.isAndroid) {
17-
WidgetsFlutterBinding.ensureInitialized();
1818
clientFactory = CronetClient.new;
1919
}
2020
runWithClient(() => runApp(const BookSearchApp()), clientFactory);
@@ -122,7 +122,10 @@ class _BookListState extends State<BookList> {
122122
itemBuilder: (context, index) => Card(
123123
key: ValueKey(widget.books[index].title),
124124
child: ListTile(
125-
leading: Image.network(widget.books[index].imageUrl),
125+
leading: CachedNetworkImage(
126+
placeholder: (context, url) =>
127+
const CircularProgressIndicator(),
128+
imageUrl: widget.books[index].imageUrl),
126129
title: Text(widget.books[index].title),
127130
subtitle: Text(widget.books[index].description),
128131
),

pkgs/cronet_http/example/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ environment:
77
sdk: ">=2.17.5 <3.0.0"
88

99
dependencies:
10+
cached_network_image: ^3.2.3
1011
cronet_http:
1112
path: ../
1213
cupertino_icons: ^1.0.2

pkgs/cupertino_http/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.0.11
2+
3+
* Fix a bug where the images in the example would be loaded using `dart:io`
4+
`HttpClient`.
5+
16
## 0.0.10
27

38
* Fix [Use of multiple CupertinoClients can result in cancelled requests](https://github.com/dart-lang/http/issues/826)

pkgs/cupertino_http/example/lib/main.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import 'dart:convert';
66
import 'dart:io';
77

8+
import 'package:cached_network_image/cached_network_image.dart';
89
import 'package:cupertino_http/cupertino_client.dart';
910
import 'package:flutter/material.dart';
1011
import 'package:http/http.dart';
@@ -121,7 +122,11 @@ class _BookListState extends State<BookList> {
121122
itemBuilder: (context, index) => Card(
122123
key: ValueKey(widget.books[index].title),
123124
child: ListTile(
124-
leading: Image.network(widget.books[index].imageUrl),
125+
leading: CachedNetworkImage(
126+
placeholder: (context, url) =>
127+
const CircularProgressIndicator(),
128+
imageUrl:
129+
widget.books[index].imageUrl.replaceFirst('http', 'https')),
125130
title: Text(widget.books[index].title),
126131
subtitle: Text(widget.books[index].description),
127132
),

pkgs/cupertino_http/example/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ environment:
99
sdk: ">=2.17.3 <3.0.0"
1010

1111
dependencies:
12+
cached_network_image: ^3.2.3
1213
cupertino_http:
1314
path: ../
1415
cupertino_icons: ^1.0.2

0 commit comments

Comments
 (0)