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

推荐订阅源

H
Help Net Security
宝玉的分享
宝玉的分享
The Cloudflare Blog
Apple Machine Learning Research
Apple Machine Learning Research
V
Visual Studio Blog
Last Week in AI
Last Week in AI
Hugging Face - Blog
Hugging Face - Blog
博客园 - 司徒正美
博客园 - 三生石上(FineUI控件)
A
About on SuperTechFans
MyScale Blog
MyScale Blog
aimingoo的专栏
aimingoo的专栏
Microsoft Security Blog
Microsoft Security Blog
D
Docker
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Recent Announcements
Recent Announcements
大猫的无限游戏
大猫的无限游戏
IT之家
IT之家
P
Proofpoint News Feed
L
LangChain Blog
Blog — PlanetScale
Blog — PlanetScale
The GitHub Blog
The GitHub 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
Firebase Hosting for Flutter Web: What Actually Works (an...
Codexlancers · 2026-06-24 · via DEV Community

When we first started deploying Flutter web apps, Firebase Hosting felt like the obvious choice.

It's fast, reliable, and backed by Google - but like most "easy" tools, things get tricky the moment you move beyond the basics.

In this blog, we're not just covering setup. We're sharing what actually works in real projects, the mistakes we've seen (and made), and a few things most guides don't talk about.

Why We Prefer Firebase Hosting for Flutter Web

We've tried different hosting solutions, but Firebase keeps coming back into our workflow for a few solid reasons:

  • Global CDN out of the box - your app loads fast everywhere
  • Free SSL - no extra configuration headaches
  • Simple deployment - one command and you're live
  • Version control with previews -helpful for testing before pushing to production

For most Flutter web apps, especially MVPs and dashboards, it just makes sense.

Quick Setup (The Practical Version)

Instead of overcomplicating things, here's the version that works:

1. Install Firebase CLI

npm install -g firebase-tools

2. Login & Initialize

firebase login
firebase init

While initializing:

  • Select Hosting
  • Choose your Firebase project
  • Set build folder to:
build/web

  • Configure as a single-page app (SPA) → YES

3. Build Flutter Web

flutter build web

4. Deploy

firebase deploy

That's it - your Flutter web app is live.

But honestly, this is the easy part. The real issues start after deployment.

The "#" in Flutter Web URLs (And Why You Should Care)

If you've deployed your app and see URLs like this:
"yourdomain.com/#/dashboard"

That # is coming from Flutter's default routing strategy.

Why it exists

Flutter uses hash-based routing because:

  • It avoids server configuration
  • Works out-of-the-box on any hosting

But

Why we remove it

From our experience, keeping # in URLs is not ideal:

  • Looks unprofessional
  • Bad for SEO
  • Harder to share clean URLs
  • Not aligned with modern web standards

How We Remove "#" from Flutter Web URLs

We switch to Path URL Strategy.

Step 1: Add this in main.dart

import 'package:flutter_web_plugins/flutter_web_plugins.dart';

void main() {
  setUrlStrategy(PathUrlStrategy());
  runApp(MyApp());
}

Step 2: Update Firebase Hosting Rewrite

In firebase.json, make sure you have:

"rewrites": [
  {
    "source": "**",
    "destination": "/index.html"
  }
]

Result

Now your URLs look clean:
"yourdomain.com/dashboard"

This small change makes a big difference in production apps.

Common Mistakes We See (Again and Again)

This is where most developers struggle - not in setup, but in the details.

1. Forgetting SPA Rewrite

Without rewrites, refreshing any route gives a 404 error.

We've seen this happen in production apps - easy to miss, painful to debug.

2. Deploying Without Testing Build

Running locally ≠ production build.

We always run:

flutter build web

and test the build/web folder before deploying.

3. Ignoring Cache Issues

Firebase aggressively caches files.
So when updates don't reflect:

  • Users still see old UI
  • API changes don't appear

Fix: Use proper cache headers or versioning.

4. Not Optimizing Build Size

Flutter web builds can get heavy.
Common mistakes:

  • Large images
  • Unused assets
  • Debug mode builds

We always:

  • Compress assets
  • Use - release build
  • Avoid unnecessary packages

5. Not Handling Environment Config Properly

Hardcoding API URLs is a common mistake.
Instead, we:

  • Use environment-based configs
  • Keep dev and prod setups separate

What We've Learned After Multiple Deployments

After working on multiple Flutter web projects, a few patterns are clear:

  • Firebase Hosting is great for speed and simplicity
  • Most issues come from configuration, not code
  • Small things (like URL strategy) make a big production difference

When Firebase Hosting Might Not Be Enough

We still use Firebase a lot, but it's not perfect for everything.
You might outgrow it if:

  • You need advanced server-side rendering
  • You want full backend control
  • You're building SEO-heavy public platforms

For dashboards, admin panels, internal tools - it's still one of the best choices.

Final Thoughts

Firebase Hosting + Flutter Web is a powerful combo - but only if you handle the details right.

Most tutorials stop at deployment.
Real-world apps fail in the gaps after that.

If you:

  • Fix routing properly
  • Avoid common mistakes
  • Optimize your build

you'll have a fast, clean, production-ready web app.

If you're working on Flutter web and stuck somewhere, chances are it's one of these small things - we've been there too.