Preview:
import 'dart:async';
import 'package:flutter/material.dart';

class CustomSplashScreen extends StatefulWidget {
  final Widget child;
  final Duration duration;
  final String image;
  final Curve transitionCurve;
  final Function()? onEnd;
  const CustomSplashScreen({
    super.key,
    required this.child,
    required this.duration,
    required this.image,
    this.transitionCurve = Curves.easeInOut,
    this.onEnd,
  });

  @override
  State<CustomSplashScreen> createState() => _CustomSplashScreenState();
}

class _CustomSplashScreenState extends State<CustomSplashScreen>
    with SingleTickerProviderStateMixin {
  bool enableSplash = true;
  late Timer timer;

  @override
  void initState() {
    super.initState();
    _initializeSplash();
  }

  void _initializeSplash() {
    timer = Timer(
      widget.duration,
      () {
        setState(() {
          enableSplash = false;
        widget.onEnd?.call();
        });
      },
    );
  }

  @override
  void dispose() {
    timer.cancel();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return AnimatedSwitcher(
      duration: const Duration(milliseconds: 500),
      switchInCurve: widget.transitionCurve,
      switchOutCurve: widget.transitionCurve,
      child: enableSplash
          ? Container(
              color: Colors.white,
              child: Center(
                child: Image.asset(
                  widget.image,
                  fit: BoxFit.cover,
                  width: double.infinity,
                  height: double.infinity,
                ),
              ),
            )
          : widget.child,
    );
  }
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter