[dart] d
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.
- // splash_screen.dart
- import 'package:flutter/material.dart';
- import 'dart:async';
- import 'home_screen.dart';
- class SplashScreen extends StatefulWidget {
- @override
- _SplashScreenState createState() => _SplashScreenState();
- }
- class _SplashScreenState extends State<SplashScreen> {
- double logoOpacity = 0.0; // Mulai dengan opasitas 0.0
- double textOpacity = 0.0; // Mulai dengan opasitas 0.0
- @override
- void initState() {
- super.initState();
- // Menjalankan animasi opasitas setelah 1 detik
- Timer(
- Duration(seconds: 1),
- () {
- setState(() {
- logoOpacity = 1.0; // Setelah 1 detik, ubah opasitas logo menjadi 1.0
- textOpacity = 1.0; // Setelah 1 detik, ubah opasitas teks menjadi 1.0
- });
- // Setelah muncul dengan jelas, jalankan animasi kedip
- startBlinkAnimation();
- },
- );
- // Pindah ke halaman beranda setelah 8 detik (3 detik untuk muncul dengan jelas + 5 detik untuk 3 kali kedip)
- Timer(
- Duration(seconds: 8),
- () {
- Navigator.of(context).pushReplacement(
- MaterialPageRoute(
- builder: (BuildContext context) => HomeScreen(),
- ),
- );
- },
- );
- }
- void startBlinkAnimation() {
- const int totalBlinks = 3;
- for (int i = 0; i < totalBlinks; i++) {
- Timer(
- Duration(
- seconds: 1 *
- (i + 2)), // Menjadwalkan kedipan setelah muncul dengan jelas
- () {
- setState(() {
- logoOpacity =
- 1.0 - logoOpacity; // Toggle opasitas antara 0.0 dan 1.0
- });
- },
- );
- }
- // Setelah 3 kali kedip, jalankan animasi menghilang
- Timer(
- Duration(seconds: 1 * (totalBlinks + 2)),
- () {
- setState(() {
- logoOpacity =
- 0.0; // Setelah 3 kali kedip, ubah opasitas logo menjadi 0.0
- textOpacity =
- 0.0; // Setelah 3 kali kedip, ubah opasitas teks menjadi 0.0
- });
- },
- );
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- body: Center(
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- AnimatedOpacity(
- opacity: logoOpacity,
- duration: Duration(seconds: 2),
- child:
- Image.asset('image/logo.png', width: 230.0, height: 230.0),
- ),
- SizedBox(height: 16.0), // Jarak antara gambar dan teks
- AnimatedOpacity(
- opacity: textOpacity,
- duration: Duration(seconds: 2),
- child: Text(
- 'Contact Me',
- style: TextStyle(
- fontSize: 24.0,
- fontWeight: FontWeight.bold,
- ),
- ),
- ),
- ],
- ),
- ),
- );
- }
- }
Editor
You can edit this paste and save as new: