[dart] splash
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
- import 'package:flutter/material.dart';
- class SplashScreen extends StatefulWidget {
- @override
- _SplashScreenState createState() => _SplashScreenState();
- }
- class _SplashScreenState extends State<SplashScreen> {
- double opacityLevel = 0.0;
- @override
- void initState() {
- super.initState();
- // Animasi fading pada elemen gambar
- Future.delayed(Duration(milliseconds: 500), () {
- setState(() {
- opacityLevel = 1.0;
- });
- });
- // Navigasi ke halaman home setelah beberapa detik
- Future.delayed(Duration(seconds: 2), () {
- Navigator.pushReplacementNamed(context, '/home');
- });
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(),
- body: Center(
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- Hero(
- tag: 'logo',
- child: AnimatedOpacity(
- opacity: opacityLevel,
- duration: Duration(milliseconds: 500),
- child: ClipOval(
- child: Image.asset(
- 'images/image_splash.jpeg',
- width: 100,
- height: 100,
- fit: BoxFit.cover,
- ),
- ),
- ),
- ),
- SizedBox(height: 16),
- Text(
- 'Contact App',
- style: TextStyle(
- fontSize: 20,
- fontFamily: 'kranky',
- ),
- ),
- ],
- ),
- ),
- );
- }
- }
Editor
You can edit this paste and save as new: