// Copyright 2019 The FlutterCandies author. All rights reserved. // Use of this source code is governed by an Apache license that can be found // in the LICENSE file. import 'package:flutter/material.dart'; import 'package:package_info_plus/package_info_plus.dart'; import '../main.dart'; import 'home_page.dart'; class SplashPage extends StatefulWidget { const SplashPage({super.key}); @override State createState() => _SplashPageState(); } class _SplashPageState extends State { @override void initState() { super.initState(); init(); } Future init() async { try { final PackageInfo info = await PackageInfo.fromPlatform(); packageVersion = info.version; } catch (_) {} await Future.delayed(const Duration(seconds: 1)); if (mounted) { Navigator.of(context).pushReplacement( PageRouteBuilder( pageBuilder: (_, __, ___) => const HomePage(), transitionsBuilder: (_, Animation a, __, Widget child) { return FadeTransition(opacity: a, child: child); }, transitionDuration: const Duration(seconds: 1), ), ); } } @override Widget build(BuildContext context) { return Material( color: Theme.of(context).canvasColor, child: Center( child: Hero( tag: 'LOGO', child: Image.asset('assets/flutter_candies_logo.png', width: 150.0), ), ), ); } }