fixing android build

This commit is contained in:
Prince
2026-06-14 13:09:14 +02:00
parent 7dc48e06e9
commit 5014b679f5
18 changed files with 91 additions and 11 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View File

@@ -1,3 +1,7 @@
org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError
android.useAndroidX=true
android.enableJetifier=true
# This builtInKotlin flag was added automatically by Flutter migrator
android.builtInKotlin=false
# This newDsl flag was added automatically by Flutter migrator
android.newDsl=false

View File

@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-all.zip

View File

@@ -18,7 +18,7 @@ pluginManagement {
plugins {
id("dev.flutter.flutter-plugin-loader") version "1.0.0"
id("com.android.application") version "8.7.0" apply false
id("com.android.application") version "8.9.1" apply false
// START: FlutterFire Configuration
id("com.google.gms.google-services") version("4.3.15") apply false
// END: FlutterFire Configuration

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 MiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

14
lib/browser.dart Normal file
View File

@@ -0,0 +1,14 @@
/// Platform-aware browser API abstraction.
///
/// On web, provides real browser localStorage and location APIs.
/// On non-web platforms (Android, iOS, desktop), returns no-op stubs.
///
/// Usage:
/// ```dart
/// import 'package:qpay/browser.dart';
/// Browser.localStorage.setItem('key', 'value');
/// Browser.localStorage.getItem('key');
/// Browser.location.href = 'https://example.com';
/// ```
export 'platform/browser_stub.dart'
if (dart.library.html) 'platform/browser_web.dart';

View File

@@ -1,8 +1,9 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
import 'package:provider/provider.dart';
import 'package:qpay/auth_state.dart';
import 'package:qpay/routes.dart';
import 'package:qpay/url_strategy.dart';
import 'package:qpay/screens/transaction_controller.dart';
import 'package:qpay/screens/onboarding/onboarding_controller.dart';
import 'package:qpay/theme/app_theme.dart';
@@ -26,7 +27,9 @@ String resolveEnvFile(String env) {
void main() async {
WidgetsFlutterBinding.ensureInitialized();
usePathUrlStrategy();
if (kIsWeb) {
usePathUrlStrategy();
}
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
await dotenv.load(fileName: resolveEnvFile(appEnv));
@@ -70,4 +73,4 @@ class _MyAppState extends State<MyApp> {
routerConfig: buildRouter(),
);
}
}
}

View 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();
}

View 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();
}

View File

@@ -0,0 +1,3 @@
/// Stub for path URL strategy on non-web platforms.
/// Does nothing since URL strategies are web-only.
void usePathUrlStrategy() {}

View 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();
}

View File

@@ -3,7 +3,7 @@ import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:go_router/go_router.dart';
import 'package:qpay/models/responsive_policy.dart';
import 'package:qpay/screens/gateway/gateway_controller.dart';
import 'package:web/web.dart' as web;
import 'package:qpay/browser.dart';
class GatewayWebScreen extends StatefulWidget {
const GatewayWebScreen({super.key});
@@ -50,7 +50,7 @@ class _GatewayWebScreenState extends State<GatewayWebScreen> {
final transactionId =
controller.transactionController.model.confirmationData['id'];
if (transactionId != null) {
web.window.localStorage.setItem(
Browser.localStorage.setItem(
'pendingTransactionId',
transactionId.toString(),
);
@@ -60,7 +60,7 @@ class _GatewayWebScreenState extends State<GatewayWebScreen> {
// After payment, the gateway will redirect back to this app's host.
// index.html then reads the saved transaction ID and navigates to
// /poll/:id so the app can immediately start polling for the result.
web.window.location.href = url;
Browser.location.href = url;
}
@override

View File

@@ -5,7 +5,7 @@ import 'package:provider/provider.dart';
import 'package:qpay/screens/gateway/gateway_controller.dart';
import 'package:qpay/screens/transaction_controller.dart';
import 'package:qpay/widgets/step_loading_widget.dart';
import 'package:web/web.dart' as web;
import 'package:qpay/browser.dart';
class PollScreen extends StatefulWidget {
final String? transactionId;
@@ -39,8 +39,8 @@ class _PollScreenState extends State<PollScreen> {
// Priority 2: localStorage (for when gateway redirect causes page reload
// and the route param path is not available due to hub redirect override)
if (transactionId == null && kIsWeb) {
transactionId = web.window.localStorage.getItem('pendingTransactionId');
web.window.localStorage.removeItem('pendingTransactionId');
transactionId = Browser.localStorage.getItem('pendingTransactionId');
Browser.localStorage.removeItem('pendingTransactionId');
}
// Priority 3: in-memory confirmation data (normal SPA navigation)

6
lib/url_strategy.dart Normal file
View File

@@ -0,0 +1,6 @@
/// Platform-aware path URL strategy.
///
/// On web, sets the path URL strategy via [usePathUrlStrategy].
/// On non-web platforms, this is a no-op.
export 'platform/url_strategy_stub.dart'
if (dart.library.html) 'platform/url_strategy_web.dart';

View File

@@ -120,6 +120,10 @@ flutter:
icons_launcher:
image_path: "assets/velocity-icon-black.png"
adaptive_background_color: "#ffffff"
adaptive_foreground_image: "assets/velocity-icon-black.png"
adaptive_round_image: "assets/velocity-icon-black.png"
notification_image: "assets/velocity-icon-black.png"
platforms:
android:
enable: true