diff --git a/lib/app/services/splash_remover_stub.dart b/lib/app/services/splash_remover_stub.dart new file mode 100644 index 0000000..63be5d1 --- /dev/null +++ b/lib/app/services/splash_remover_stub.dart @@ -0,0 +1,7 @@ +/// A stub implementation of the splash remover for non-web platforms. +/// +/// This function does nothing, as splash screen removal is only handled +/// on the web. +void removeSplashFromWeb() { + // No-op for non-web platforms. +} diff --git a/lib/app/services/splash_remover_web.dart b/lib/app/services/splash_remover_web.dart new file mode 100644 index 0000000..290bba2 --- /dev/null +++ b/lib/app/services/splash_remover_web.dart @@ -0,0 +1,6 @@ +import 'dart:js_interop'; + +/// Web-specific implementation that calls the JavaScript function +/// to remove the splash screen. +@JS('removeSplashFromWeb') +external void removeSplashFromWeb(); diff --git a/lib/app/services/web_splash.dart b/lib/app/services/web_splash.dart new file mode 100644 index 0000000..a141192 --- /dev/null +++ b/lib/app/services/web_splash.dart @@ -0,0 +1,2 @@ +export 'splash_remover_stub.dart' + if (dart.library.html) 'splash_remover_web.dart'; diff --git a/lib/main.dart b/lib/main.dart index 57e539d..f1ffe48 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,6 +1,5 @@ -import 'dart:js_interop'; - import 'package:device_preview/device_preview.dart'; +import 'package:flutter_news_app_mobile_client_full_source_code/app/services/web_splash.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_news_app_mobile_client_full_source_code/app/config/config.dart'; @@ -9,9 +8,6 @@ import 'package:flutter_news_app_mobile_client_full_source_code/bootstrap.dart'; // Define the current application environment (production/development/demo). const appEnvironment = AppEnvironment.development; -@JS('removeSplashFromWeb') -external void removeSplashFromWeb(); - void main() async { final appConfig = switch (appEnvironment) { AppEnvironment.production => AppConfig.production(),