fixing android build
This commit is contained in:
18
lib/platform/browser_stub.dart
Normal file
18
lib/platform/browser_stub.dart
Normal file
@@ -0,0 +1,18 @@
|
||||
/// Stub implementation of browser APIs for non-web platforms.
|
||||
class BrowserStorage {
|
||||
String? getItem(String key) => null;
|
||||
void setItem(String key, String value) {}
|
||||
void removeItem(String key) {}
|
||||
}
|
||||
|
||||
/// Stub for window.location
|
||||
class BrowserLocation {
|
||||
String get href => '';
|
||||
set href(String value) {}
|
||||
}
|
||||
|
||||
/// Browser utility class for non-web platforms.
|
||||
class Browser {
|
||||
static final BrowserStorage localStorage = BrowserStorage();
|
||||
static final BrowserLocation location = BrowserLocation();
|
||||
}
|
||||
22
lib/platform/browser_web.dart
Normal file
22
lib/platform/browser_web.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
import 'package:web/web.dart' as web;
|
||||
|
||||
/// Web implementation of browser APIs using package:web.
|
||||
class BrowserStorage {
|
||||
String? getItem(String key) => web.window.localStorage.getItem(key);
|
||||
void setItem(String key, String value) =>
|
||||
web.window.localStorage.setItem(key, value);
|
||||
void removeItem(String key) =>
|
||||
web.window.localStorage.removeItem(key);
|
||||
}
|
||||
|
||||
/// Web implementation for window.location
|
||||
class BrowserLocation {
|
||||
String get href => web.window.location.href;
|
||||
set href(String value) => web.window.location.href = value;
|
||||
}
|
||||
|
||||
/// Browser utility class using package:web.
|
||||
class Browser {
|
||||
static final BrowserStorage localStorage = BrowserStorage();
|
||||
static final BrowserLocation location = BrowserLocation();
|
||||
}
|
||||
3
lib/platform/url_strategy_stub.dart
Normal file
3
lib/platform/url_strategy_stub.dart
Normal file
@@ -0,0 +1,3 @@
|
||||
/// Stub for path URL strategy on non-web platforms.
|
||||
/// Does nothing since URL strategies are web-only.
|
||||
void usePathUrlStrategy() {}
|
||||
6
lib/platform/url_strategy_web.dart
Normal file
6
lib/platform/url_strategy_web.dart
Normal file
@@ -0,0 +1,6 @@
|
||||
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
|
||||
|
||||
/// Web implementation that sets the path URL strategy.
|
||||
void usePathUrlStrategy() {
|
||||
flutter_web_plugins.usePathUrlStrategy();
|
||||
}
|
||||
Reference in New Issue
Block a user