@@ -2,30 +2,29 @@ import 'dart:async';
22import 'dart:convert' ;
33import 'dart:developer' ;
44
5- import 'package:http/http.dart' ;
5+ import 'package:http/http.dart' as http ;
66
77import '../../codelessly_sdk.dart' ;
88
99/// A [NetworkDataRepository] implementation that utilizes the Firebase Cloud
1010/// Functions to retrieve the relevant data.
11- ///
12- /// Since Firedart is not compatible with Flutter Web, this implementation
13- /// utilizes the http package instead.
1411@Deprecated ('Use [FirebaseDataRepository] instead.' )
1512class WebDataRepository extends NetworkDataRepository {
13+ final http.Client client;
14+
1615 /// Creates a [WebDataRepository] instance.
1716 WebDataRepository ({
1817 required super .config,
1918 required super .tracker,
19+ required this .client,
2020 });
2121
2222 @override
2323 Stream <SDKPublishModel ?> streamPublishModel ({
2424 required String projectID,
2525 required PublishSource source,
2626 }) async * {
27- // TODO(Saad): Use an HTTP client.
28- final Response result = await post (
27+ final http.Response result = await client.post (
2928 Uri .parse (
3029 '${config .firebaseCloudFunctionsBaseURL }/api/getPublishModelRequest' ),
3130 headers: < String , String > {'Content-Type' : 'application/json' },
@@ -57,8 +56,7 @@ class WebDataRepository extends NetworkDataRepository {
5756 required String layoutID,
5857 required PublishSource source,
5958 }) async {
60- // TODO(Saad): Use an HTTP client.
61- final Response result = await post (
59+ final http.Response result = await client.post (
6260 Uri .parse (
6361 '${config .firebaseCloudFunctionsBaseURL }/api/getLayoutModelRequest' ),
6462 headers: < String , String > {'Content-Type' : 'application/json' },
@@ -94,8 +92,7 @@ class WebDataRepository extends NetworkDataRepository {
9492 required PublishSource source,
9593 }) async {
9694 try {
97- // TODO(Saad): Use an HTTP client.
98- final Response result = await post (
95+ final http.Response result = await client.post (
9996 Uri .parse (
10097 '${config .firebaseCloudFunctionsBaseURL }/api/getFontModelRequest' ),
10198 headers: < String , String > {'Content-Type' : 'application/json' },
@@ -132,8 +129,7 @@ class WebDataRepository extends NetworkDataRepository {
132129 required PublishSource source,
133130 }) async {
134131 try {
135- // TODO(Saad): Use an HTTP client.
136- final Response result = await post (
132+ final http.Response result = await client.post (
137133 Uri .parse (
138134 '${config .firebaseCloudFunctionsBaseURL }/api/getPublishedApiRequest' ),
139135 headers: < String , String > {'Content-Type' : 'application/json' },
@@ -172,8 +168,7 @@ class WebDataRepository extends NetworkDataRepository {
172168 required PublishSource source,
173169 }) async {
174170 try {
175- // TODO(Saad): Use an HTTP client.
176- final Response result = await post (
171+ final http.Response result = await client.post (
177172 Uri .parse (
178173 '${config .firebaseCloudFunctionsBaseURL }/api/getPublishedLayoutVariablesRequest' ),
179174 headers: < String , String > {'Content-Type' : 'application/json' },
@@ -214,8 +209,7 @@ class WebDataRepository extends NetworkDataRepository {
214209 }) async {
215210 log ('[WebDataRepo] Downloading conditions for $layoutID ' );
216211 try {
217- // TODO(Saad): Use an HTTP client.
218- final Response result = await post (
212+ final http.Response result = await client.post (
219213 Uri .parse (
220214 '${config .firebaseCloudFunctionsBaseURL }/api/getPublishedLayoutConditionsRequest' ),
221215 headers: < String , String > {'Content-Type' : 'application/json' },
0 commit comments