Closed abdelaziz-mahdy closed 12 months ago
i had to add in main function to make it work but in 2.3.5 i didnt have to do it
WidgetsFlutterBinding.ensureInitialized();
FlutterNativeSplash.remove();
and on app hot restart i get this
Error: PlatformException(error, Exception: Did you forget to run "dart run flutter_native_splash:create"?
Could not run the JS command removeSplashFromWeb(), null, null)
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 294:3 throw_
packages/flutter/src/services/message_codecs.dart 651:7 decodeEnvelope
packages/flutter/src/services/platform_channel.dart 322:18 _invokeMethod
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 45:50 <fn>
dart-sdk/lib/async/zone.dart 1661:54 runUnary
dart-sdk/lib/async/future_impl.dart 162:18 handleValue
dart-sdk/lib/async/future_impl.dart 846:44 handleValueCallback
but this hides my loading indicator mentioned here https://github.com/jonbhanson/flutter_native_splash/issues/619
a workaround i did was set, dont know if that the correct way
.container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
width: 100%;
margin-top: 100px; /* Added a margin to shift it down a bit */
z-index: 999999; /* Higher than the splash screen */
position: relative; /* Required for z-index to take effect */
}
@jonbhanson
Hello!
I am already working on fixing this...
I have the solution, I will create a pull request for it tonight.
I have the solution, I will create a pull request for it tonight.
if in need of any help let me know, since i was going to provide a fix for the hot restart problem, after i finish work too
my idea is to update
<script id="splash-screen-script">
function removeSplashFromWeb() {
const splashElement = document.getElementById("splash");
splashElement.classList.add("remove");
setTimeout(function () {
splashElement.remove();
document.getElementById("splash-screen-script")?.remove();
}, 750 /* animation time + wait rendering and others(500ms) */);
}
</script>
to not remove the function removeSplashFromWeb and just update it to check if elements exists it should delete it if not it should do nothing
by chatgpt (not tested yet)
<script id="splash-screen-script">
function removeSplashFromWeb() {
const splashElement = document.getElementById("splash");
if (splashElement) {
splashElement.classList.add("remove");
setTimeout(function () {
splashElement.remove();
}, 750 /* animation time + wait rendering and others(500ms) */);
}
}
</script>
I have the solution, I will create a pull request for it tonight.
Great, I look forward to it, thanks!
@eggp
btw i just tested
<script id="splash-screen-script">
function removeSplashFromWeb() {
const splashElement = document.getElementById("splash");
if (splashElement) {
splashElement.classList.add("remove");
setTimeout(function () {
splashElement.remove();
}, 750 /* animation time + wait rendering and others(500ms) */);
}
}
</script>
and having main function as
void main() {
WidgetsFlutterBinding.ensureInitialized();
FlutterNativeSplash.remove();
//run app
}
fixed the hot reload
incase if @jonbhanson dont want to introduce the new function initWeb
(to have the same functions on all platforms)
I think the best way to resolve this is to roll back the change, and then release it as a breaking change in a major version. I will push out an update shortly. Thanks for your help on this @zezo357 and @eggp.
Hello @jonbhanson!
In this case, it would be good to find a solution for the splash to be removed automatically. Unfortunately, I don't have enough knowledge in Flutter yet, and so far, I haven't found a solution to detect the first render.
Describe the bug
when creating native splash screen for web using version 2.3.6 it doesnt get removed when app loads
but on 2.3.5 it does get removed Configuration
Device (please complete the following information):
To Reproduce Steps to reproduce the behavior, using the example app:
dart run flutter_native_splash:create
using version 2.3.6 and 2.3.5Screenshots If applicable, add screenshots to help explain your problem. If in doubt, attach a screenshot.
Additional context Add any other context about the problem here.