惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Hugging Face - Blog
Hugging Face - Blog
宝玉的分享
宝玉的分享
G
Google Developers Blog
T
Tailwind CSS Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
V
V2EX
V
Visual Studio Blog
博客园 - Franky
S
SegmentFault 最新的问题
Jina AI
Jina AI
爱范儿
爱范儿
The Cloudflare Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
D
DataBreaches.Net
C
Check Point Blog
月光博客
月光博客
P
Proofpoint News Feed
T
The Blog of Author Tim Ferriss
罗磊的独立博客
H
Hackread – Cybersecurity News, Data Breaches, AI and More
MongoDB | Blog
MongoDB | Blog
The GitHub Blog
The GitHub Blog
Y
Y Combinator Blog
Martin Fowler
Martin Fowler

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Add Loading Indicator for Flutter Web
Hashem · 2026-04-25 · via DEV Community
Cover image for Add Loading Indicator for Flutter Web

Hashem

You’ve created your Flutter web app, but it takes a moment to render in the browser—and that gives your users the impression that your app isn’t working.

The blue line indicator is added by Flutter in debug mode and is removed in the release version of your app. Even after that indicator is gone, there is still about a 1-second delay for the Flutter framework to fully boot up.

Create Loading Indicator

Create a file named styles.css in the following path: web/assets, and paste the code below. This creates a CSS loading indicator that we’ll display while the Flutter framework boots.

svg path,
svg rect {
  fill: #F9BC32;
}

.spinner {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

Enter fullscreen mode Exit fullscreen mode

Then, reference the stylesheet in your index.html file inside the <head> tag:

<link rel="stylesheet" type="text/css" href="assets/styles.css">

Enter fullscreen mode Exit fullscreen mode

Now our loading indicator is ready to be shown. In the <body> tag, add the spinner:

<div class="spinner">
  <svg version="1.1" id="loader-1" xmlns="http://www.w3.org/2000/svg"
       xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
       width="60px" height="60px" viewBox="0 0 40 40"
       enable-background="new 0 0 40 40" xml:space="preserve">

    <path opacity="0.2" fill="#000"
      d="M20.201,5.169c-8.254,0-14.946,6.692-14.946,14.946
      c0,8.255,6.692,14.946,14.946,14.946
      s14.946-6.691,14.946-14.946
      C35.146,11.861,28.455,5.169,20.201,5.169z
      M20.201,31.749c-6.425,0-11.634-5.208-11.634-11.634
      c0-6.425,5.209-11.634,11.634-11.634
      c6.425,0,11.633,5.209,11.633,11.634
      C31.834,26.541,26.626,31.749,20.201,31.749z" />

    <path fill="#000"
      d="M26.013,10.047l1.654-2.866
      c-2.198-1.272-4.743-2.012-7.466-2.012h0v3.312h0
      C22.32,8.481,24.301,9.057,26.013,10.047z">

      <animateTransform attributeType="xml"
        attributeName="transform"
        type="rotate"
        from="0 20 20"
        to="360 20 20"
        dur="0.5s"
        repeatCount="indefinite" />

    </path>
  </svg>
</div>

Enter fullscreen mode Exit fullscreen mode

This will display the spinner in the center of your index.html page.

Hide Loading Indicator

Now, how do we hide it after the web app loads?

With the power of JavaScript, we can listen to a special Flutter event called flutter-first-frame. This event is broadcast when the first frame is rendered. At that moment, we remove the spinner from the page.

Add the following script inside the <body> tag:

<script>
  window.addEventListener('flutter-first-frame', function () {
    var el = document.getElementsByClassName('spinner')[0];
    el.remove();
  });
</script>

Enter fullscreen mode Exit fullscreen mode

There are other events, but they are triggered earlier and would cause the spinner to disappear too soon. As you may have noticed, the blue bar disappears early, but our spinner remains visible until the app is actually ready.

Done!

That’s it—you now have a clean loading experience for your Flutter web app.