browser_client_stub.dart 1.2 KB

1234567891011121314151617181920212223242526272829
  1. // Stub file for BrowserClient on non-web platforms
  2. // This file is used when dart.library.io is available (mobile/desktop)
  3. import 'package:http/http.dart' as http;
  4. /// Stub implementation of BrowserClient for non-web platforms.
  5. /// This class provides the same interface as the real BrowserClient
  6. /// but withCredentials is a no-op on non-web platforms.
  7. ///
  8. /// Note: This stub is never actually instantiated on non-web platforms
  9. /// (the code uses http.Client() instead), but it's needed for type compatibility.
  10. class BrowserClient extends http.BaseClient {
  11. bool _withCredentials = false;
  12. /// Controls whether credentials are sent with cross-site requests.
  13. /// This is a no-op on non-web platforms (mobile/desktop).
  14. bool get withCredentials => _withCredentials;
  15. set withCredentials(bool value) {
  16. _withCredentials = value;
  17. }
  18. // REQUIRED: BaseClient is abstract and requires send() to be implemented
  19. @override
  20. Future<http.StreamedResponse> send(http.BaseRequest request) {
  21. // Delegate to a standard client (this should never be called on non-web)
  22. return http.Client().send(request);
  23. }
  24. // OPTIONAL: close() has a default empty implementation in BaseClient
  25. // We can omit it since BaseClient provides a default
  26. }