Skip to content
Tutorial emka
Menu
  • Home
  • Debian Linux
  • Ubuntu Linux
  • Red Hat Linux
Menu

Tutorial Flutter: Animasi Blink Pada Teks

Posted on December 12, 2023

Flutter, dengan kerangka UI ekspresifnya, memungkinkan pengembang membuat pengalaman pengguna yang menarik melalui animasi. Dalam posting blog ini, kita akan membongkar sebuah widget Flutter yang disebut TapToScanTicker yang menggabungkan animasi fading in-and-out menggunakan AnimationController dan TweenSequence.

Memahami Widget Flutter

Mari kita mulai dengan memeriksa widget Flutter yang disediakan dalam source code:

class TapToScanTicker extends StatefulWidget {
  const TapToScanTicker({Key? key}) : super(key: key);

  @override
  createState() => _TapToScanTickerState();
}

class _TapToScanTickerState extends State
    with SingleTickerProviderStateMixin {
  late AnimationController _controller;
  late Animation _fadeInOut;

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

    // Inisialisasi AnimationController
    _controller =
        AnimationController(vsync: this, duration: const Duration(seconds: 2));

    // Buat urutan Tween untuk fading in dan out
    _fadeInOut = TweenSequence([
      TweenSequenceItem(tween: Tween(begin: 0.0, end: 2.0), weight: 2),
      TweenSequenceItem(tween: Tween(begin: 2.0, end: 0.0), weight: 2),
    ]).animate(_controller);

    // Mulai loop animasi
    _controller.repeat(reverse: true);
  }

  @override
  Widget build(BuildContext context) {
    return FadeTransition(
      opacity: _fadeInOut,
      child: Text(
        'Tap to scan'.toUpperCase(),
        style: AppText.b1b?.copyWith(color: AppColors.antiqueRuby),
      ),
    );
  }

  @override
  void dispose() {
    // Dispose AnimationController untuk membebaskan sumber daya
    _controller.dispose();
    super.dispose();
  }
}

Rincian Widget

  • Class TapToScanTicker: Kelas ini adalah stateful widget yang membuat instance dari _TapToScanTickerState.

  • Class _TapToScanTickerState: Kelas state ini memperluas State dan menyertakan SingleTickerProviderStateMixin untuk menyediakan vsync untuk AnimationController.
  • initState: Metode ini menginisialisasi animation controller dan menyiapkan animasi fading in-and-out menggunakan TweenSequence.

  • build: Metode build mengembalikan widget FadeTransition yang menerapkan animasi fading ke widget Text yang menampilkan “Tap to scan”.

  • dispose: Metode dispose dipanggil saat widget dihapus dari pohon widget, memastikan bahwa AnimationController dihancurkan dengan benar untuk membebaskan sumber daya.

  • Inti dari widget ini terletak pada logika animasinya. TweenSequence digunakan untuk mendefinisikan urutan tween, menciptakan transisi yang mulus antara nilai-nilai. Dalam kasus ini, animasinya bergantian antara fading in (opacity meningkat) dan fading out (opacity berkurang).

  • Animasi dikontrol oleh AnimationController yang mengulang urutan secara terbalik, menciptakan efek fading in-and-out yang kontinu.

Integrasi Widget

Untuk mengintegrasikan widget TapToScanTicker ke dalam aplikasi Flutter kalian, cukup masukkan ke dalam pohon widget kalian. Contohnya:

class LayarKalian extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: TapToScanTicker(),
      ),
    );
  }
}

Sekarang, kalian memiliki animasi yang halus namun menarik yang mengundang pengguna untuk “Tap to scan” dalam aplikasi Flutter kalian.

Eksperimen dengan widget ini, ubah durasinya, atau sesuaikan gaya teks untuk mengintegrasikannya secara mulus ke dalam desain aplikasi kalian. Kemampuan animasi Flutter memberikan kemungkinan tak terbatas untuk menciptakan antarmuka pengguna yang menyenangkan.

Selamat mencoba lek!

Recent Posts

  • How Check and Fix SELinux Block Things in Fedora Linux
  • How Actually SELinux is Work?
  • How to Install Elementary OS 8 Easy and Make It Good
  • How to Install UniFi OS Server on Ubuntu Linux Without Cloud Key
  • Top DNF5 Tips to Make Your Fedora Linux Super Fast
  • Run Local AI on Fedora 44 CPU Without Expensive GPU
  • Google Gemini Live Redesign: Works with more ‘Connected Apps’ on Android
  • A new LILYGO T3S3 ESP32-S3 with LoRA, WiFi & Bluetooth is Released only $16
  • New ESP32 Project: OpenTrafficMap ESP32-C5 C-ITS With 802.11p V2X communication
  • How to Unlock the Hidden Potential of Your Kindle with Amazing Community Plugins
  • How to Use Waze with Android Auto for the Ultimate Driving Experience
  • How to Transform Your GNOME Desktop with GNOME Prism
  • Why Your Google Maps Wear OS Navigation Fails While Using Android Auto
  • Packagist Attacked! How to Detect Hidden Malware Like This?
  • Claude Mythos Keeps Find High-severity Flaws, What You Should You Do?
  • How to Secure Your PHP Applications Against the Recent Laravel-Lang Supply Chain Attack and Credential Stealers
  • How to Protect Your Server from the LiteSpeed cPanel Plugin Privilege Escalation Vulnerability
  • How to build a high-performance private photo cloud with Immich and TrueNAS SCALE
  • How to Build an Endgame Local AI Agent Setup Using an 8-Node NVIDIA Cluster with 1TB Memory
  • How to Master Windows Event Logs to Level Up Your Cybersecurity Investigations and SOC Career
  • How to Build Ultra-Resilient Databases with Amazon Aurora Global Database and RDS Proxy for Maximum Uptime and Performance
  • How to Build Real-Time Personalization Systems Using AWS Agentic AI to Make Every User Feel Special
  • How to Transform Your Windows 11 Interface into a Sleek and Modern Aesthetic Masterpiece
  • How to Understand Google’s New TPU 8 Series for Massive AI Training and Inference
  • How to Level Up Your PC Gaming Experience with the New Valve Steam Controller and Its Advanced Features
  • Inilah Caranya Plotting Bidang Tanah Mandiri Lewat Aplikasi Sentuh Tanahku Supaya Data Jenengan Makin Akurat
  • Inilah Debut Yua Mikami di Drama Netflix Sins of Kujo, Perannya Bikin Banyak Orang Kaget!
  • Inilah Alasan Kenapa Video Viral Rok Hijau di Dapur Jadi Trending Topik dan Bikin Geger Netizen
  • Inilah Arti Rizz yang Viral di Media Sosial dan Rahasia Punya Karisma Alami Tanpa Perlu Banyak Gaya
  • Inilah Cara Menghapus Game Steam Sampai Bersih Biar Penyimpanan Lega dan Library Tetap Rapi
  • How to Automate Your Entire SEO Strategy Using a Swarm of 100 Free AI Agents Working in Parallel
  • How to create professional presentations easily using NotebookLM’s AI power for school projects and beyond
  • How to Master SEO Automation with Google Gemini 3.1 Flash-Lite in Google AI Studio
  • How to create viral AI video ads and complete brand assets using the Claude and Higgsfield MCP integration
  • How to Transform Your Mac Into a Supercharged AI Assistant with Perplexity Personal Computer
  • Apa itu Spear-Phishing via npm? Ini Pengertian dan Cara Kerjanya yang Makin Licin
  • Apa Itu Predator Spyware? Ini Pengertian dan Kontroversi Penghapusan Sanksinya
  • Mengenal Apa itu TONESHELL: Backdoor Berbahaya dari Kelompok Mustang Panda
  • Siapa itu Kelompok Hacker Silver Fox?
  • Apa itu CVE-2025-52691 SmarterMail? Celah Keamanan Paling Berbahaya Tahun 2025
©2026 Tutorial emka | Design: Newspaperly WordPress Theme