Skip to content

Commit 7009794

Browse files
committed
feat: Remove splash screen on web after load
- Call JS to remove splash - Run only on web builds
1 parent ffadc15 commit 7009794

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/main.dart

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import 'dart:js_interop';
2+
3+
import 'package:device_preview/device_preview.dart';
14
import 'package:flutter/foundation.dart';
25
import 'package:flutter/material.dart';
3-
import 'package:device_preview/device_preview.dart';
46
import 'package:ht_main/app/config/config.dart';
57
import 'package:ht_main/bootstrap.dart';
68

@@ -9,6 +11,9 @@ import 'package:ht_main/bootstrap.dart';
911
// production/development/demo
1012
const currentEnvironment = AppEnvironment.demo;
1113

14+
@JS('removeSplashFromWeb')
15+
external void removeSplashFromWeb();
16+
1217
void main() async {
1318
final appConfig = switch (currentEnvironment) {
1419
AppEnvironment.production => AppConfig.production(),
@@ -18,13 +23,17 @@ void main() async {
1823

1924
final appWidget = await bootstrap(appConfig);
2025

26+
// Only remove the splash screen on web after the app is ready.
27+
if (kIsWeb) {
28+
removeSplashFromWeb();
29+
}
30+
2131
if (appConfig.environment == AppEnvironment.demo) {
2232
runApp(
2333
DevicePreview(
2434
enabled: true,
2535
builder: (context) => appWidget,
2636
tools: const [DeviceSection()],
27-
2837
),
2938
);
3039
} else {

0 commit comments

Comments
 (0)