Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## [1.2.2] - Add web support

## [1.2.1] - Increase HTTP Status Code max success range from 300 to 304

## [1.2.0] - Add new parameter to allow response from mock with Plain Text
Expand Down
16 changes: 13 additions & 3 deletions lib/src/api_manager.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import 'dart:convert';
import 'dart:io';
import 'package:dio/browser.dart';
import 'package:flutter/foundation.dart';

import 'package:dio/dio.dart';
import 'package:dio/io.dart';
Expand All @@ -23,9 +25,17 @@ class ApiManager extends IApiManager {
_dioAdapter = DioAdapter(dio: this);
httpClientAdapter = _dioAdapter;
} else if (createHttpClient != null) {
final ioHttpClientAdapter = IOHttpClientAdapter();
ioHttpClientAdapter.createHttpClient = createHttpClient;
httpClientAdapter = ioHttpClientAdapter;
late final HttpClientAdapter _httpClientAdapter;
if (kIsWeb) {
_httpClientAdapter = BrowserHttpClientAdapter(
withCredentials: false,
);
} else {
_httpClientAdapter = IOHttpClientAdapter();
(_httpClientAdapter as IOHttpClientAdapter).createHttpClient =
createHttpClient;
}
httpClientAdapter = _httpClientAdapter;
}

options = BaseOptions(
Expand Down
3 changes: 2 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: pop_network
description: The plug-in built to simplify HTTP requests and help the developer to make good use of the Rest API's.
version: 1.2.1
version: 1.2.2
homepage: https://github.com/PopcodeMobile/popnetwork
repository: https://github.com/PopcodeMobile/popnetwork

Expand All @@ -10,6 +10,7 @@ environment:

dependencies:
dio: ^5.8.0+1
foundation: ^0.0.5
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Esse aqui é um package abandonado.

Suggested change
foundation: ^0.0.5

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdade! Apesar do kIsWeb dentro da lib ser algo simples, é melhor usar direto a comparação pura, sem a lib

Pode remover a dependência e substituir o kIsWeb por bool.fromEnvironment('dart.library.js_util'), que verifica se tem um js.util rodando no ambiente

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

O package foundation do próprio flutter já tem o kIsWeb então tá tranquilo, bastaria remover essa linha aqui, nem precisa mexer no código 🙏

http_mock_adapter: ^0.6.1

dev_dependencies:
Expand Down