123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- // 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<SplashPage> createState() => _SplashPageState();
- }
- class _SplashPageState extends State<SplashPage> {
- @override
- void initState() {
- super.initState();
- init();
- }
- Future<void> init() async {
- try {
- final PackageInfo info = await PackageInfo.fromPlatform();
- packageVersion = info.version;
- } catch (_) {}
- await Future<void>.delayed(const Duration(seconds: 1));
- if (mounted) {
- Navigator.of(context).pushReplacement(
- PageRouteBuilder<void>(
- pageBuilder: (_, __, ___) => const HomePage(),
- transitionsBuilder: (_, Animation<double> 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),
- ),
- ),
- );
- }
- }
|