Skip to content

Commit

Permalink
Add warning log to BrowserHttpClientAdapter
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhnroyal committed Aug 9, 2023
1 parent 076b141 commit 3b684a7
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions dio/lib/src/adapters/browser_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:async';
import 'dart:convert';
import 'dart:html';
import 'dart:typed_data';
import 'dart:developer' as dev;

import 'package:meta/meta.dart';

Expand All @@ -10,6 +11,13 @@ import '../dio_exception.dart';
import '../headers.dart';
import '../options.dart';

// For the web platform, an inline `bool.fromEnvironment` translates to
// `core.bool.fromEnvironment` instead of correctly being replaced by the
// constant value found in the environment at build time.
//
// See https://github.com/flutter/flutter/issues/51186.
const _kReleaseMode = bool.fromEnvironment('dart.vm.product');

HttpClientAdapter createAdapter() => BrowserHttpClientAdapter();

/// The default [HttpClientAdapter] for Web platforms.
Expand Down Expand Up @@ -218,6 +226,15 @@ class BrowserHttpClientAdapter implements HttpClientAdapter {
});

if (requestStream != null) {
if (!_kReleaseMode && options.method == 'GET') {
dev.log(
'GET request with a body data are not support on the '
'web platform. Use POST/PUT instead.',
level: 900,
name: '🔔 Dio',
stackTrace: StackTrace.current,
);
}
final completer = Completer<Uint8List>();
final sink = ByteConversionSink.withCallback(
(bytes) => completer.complete(Uint8List.fromList(bytes)),
Expand Down

0 comments on commit 3b684a7

Please sign in to comment.