🚨 Fix web compile with the native http client
This commit is contained in:
parent
05425da913
commit
f1abf94399
12
lib/providers/adapters/sn_network_native.dart
Normal file
12
lib/providers/adapters/sn_network_native.dart
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:dio/dio.dart';
|
||||||
|
import 'package:native_dio_adapter/native_dio_adapter.dart';
|
||||||
|
|
||||||
|
Dio addClientAdapter(Dio client) {
|
||||||
|
if (Platform.isAndroid || Platform.isIOS || Platform.isMacOS) {
|
||||||
|
// Switch to native implementation if possible
|
||||||
|
client.httpClientAdapter = NativeAdapter();
|
||||||
|
}
|
||||||
|
return client;
|
||||||
|
}
|
2
lib/providers/adapters/sn_network_universal.dart
Normal file
2
lib/providers/adapters/sn_network_universal.dart
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export 'package:surface/providers/adapters/sn_network_web.dart'
|
||||||
|
if (dart.library.io) 'package:surface/providers/adapters/sn_network_native.dart';
|
5
lib/providers/adapters/sn_network_web.dart
Normal file
5
lib/providers/adapters/sn_network_web.dart
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import 'package:dio/dio.dart';
|
||||||
|
|
||||||
|
Dio addClientAdapter(Dio client) {
|
||||||
|
return client;
|
||||||
|
}
|
@ -1,12 +1,10 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:dio_smart_retry/dio_smart_retry.dart';
|
import 'package:dio_smart_retry/dio_smart_retry.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||||
import 'package:native_dio_adapter/native_dio_adapter.dart';
|
import 'package:surface/providers/adapters/sn_network_universal.dart';
|
||||||
|
|
||||||
const kUseLocalNetwork = true;
|
const kUseLocalNetwork = true;
|
||||||
|
|
||||||
@ -87,10 +85,7 @@ class SnNetworkProvider {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!kIsWeb && (Platform.isAndroid || Platform.isIOS || Platform.isMacOS)) {
|
client = addClientAdapter(client);
|
||||||
// Switch to native implementation if possible
|
|
||||||
client.httpClientAdapter = NativeAdapter();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String getAttachmentUrl(String ky) {
|
String getAttachmentUrl(String ky) {
|
||||||
|
Loading…
Reference in New Issue
Block a user