I made a web flutter app, with custom splash screen, and for some reason it reloads twice and it happens only on realise. It also happens on the splash screen. It also happens only on first load, and then this issue does not appear for some time. So here is Splash screen code:
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:nagolove/pages/home.dart';
class SplashScreenLogo extends StatefulWidget {
const SplashScreenLogo({Key? key}) : super(key: key);
@override
State<SplashScreenLogo> createState() => SplashScreenLogoState();
}
class SplashScreenLogoState extends State<SplashScreenLogo> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xff1A2534),
body: RepaintBoundary(
child: TweenAnimationBuilder<double>(
duration: const Duration(milliseconds: 2500),
tween: Tween<double>(begin: 0.0, end: 1.0),
builder: (context, value, _) {
if (value == 1.0) {
return TweenAnimationBuilder<double>(
duration: const Duration(milliseconds: 4000),
curve: Curves.fastLinearToSlowEaseIn,
tween: Tween<double>(begin: 5.0, end: 20.0),
builder: (context, value, child) {
return Center(
child: Container(
height: value * 10,
width: value * 10,
decoration: BoxDecoration(
color: Colors.transparent,
border: const Border(
left: BorderSide(
color: Colors.transparent,
width: 3.0,
),
),
boxShadow: [
BoxShadow(
color: Colors.deepPurpleAccent.withOpacity(0.4),
blurRadius: 60.0,
spreadRadius: 5.0,
),
],
),
child: FittedBox(
child: SvgPicture.asset(
"assets/Svg/splash/Icon.svg",
),
),
),
);
},
onEnd: () {
//setState(() {
Navigator.of(context).pushReplacement( //
ThisIsFadeRoute(),
);
//});
});
}
return Container();
},
),
),
);
}
}
class ThisIsFadeRoute extends PageRouteBuilder {
ThisIsFadeRoute()
: super(
pageBuilder: (BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation) {
return const HomePage();
},
transitionsBuilder: (
BuildContext context,
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child,
) {
return FadeTransition(
opacity: animation,
child: const HomePage(),
);
},
transitionDuration: const Duration(milliseconds: 1000),
);
}
Here is the link to face the issue, please test on mobile: https://nagolove-d8d94--channel-id-ae4qrqcq.web.app
Please help, I cant realise what causes it.