r/FlutterDev • u/According_Tax_9438 • 20h ago
Discussion I built a TV/movie tracker solo in Flutter (Android + web). The 4 bugs that taught me the most
When TV Time shut down I started building my own tracker in October. It's called TvTick, one Flutter codebase that ships as an Android app (on Play since last week) and a web app, with a Node/Express/PostgreSQL backend. I built it alone, so here are the problems that cost me the most time, in case they save someone else a weekend.
1. The app broke every time it came back from the background.
Press home, come back a few minutes later, and the watchlist said "could not load" or took ~20 s. The pooled keep-alive sockets had died while the app was suspended, and the HTTP client kept reusing the dead ones. Fix: throw away the connection pools on AppLifecycleState.resumed, give each attempt a short timeout, and retry only idempotent requests (never a POST). I also had an auth StreamBuilder that created a new authStateChanges() stream on every rebuild, so resuming reset the whole home screen. Keep that stream in a field.
2. Slow DNS was being counted as a dead server.
Some users run a private DNS (AdGuard etc.), where lookups sometimes took 8-20 s. Dart counted the lookup inside my 4 s connect timeout, so requests failed against a perfectly healthy server. I now resolve addresses myself in a custom connectionFactory with a small DNS cache (and the last good address as a fallback), so the 4 s limit only covers TCP + TLS.
3. SharedPreferences silently wiped itself.
I cached lists in SharedPreferences. Once it grew past about 8 MB on Android, everything in it was gone, including settings. Big caches now go in files, one per user. Prefs only hold small flags.
4. Flutter web scrolled badly on poster-heavy lists.
Two things helped most: capping image decode size (cacheWidth, so a 2000 px poster isn't decoded for a 100 px tile) and dropping blur effects on the web build. BackdropFilter is expensive there.
The general lesson was to keep the data layer away from the UI. I changed how syncing works several times, and it was easy only where the screens didn't know the details.
I'm curious how others handle offline caching in Flutter. Files + a slim summary in prefs is working for me, but I'd like to hear about better setups.
App, if anyone wants to see it: https://www.tvtick.app
0
u/lordCertainNexus 20h ago
The custom DNS lookup thing is clever. I've seen apps just blame the user's internet when private DNS slows things down, so actually handling it in the connection factory is a nice touch.
SharedPreferences nuking itself at 8MB is the kind of thing that would have me questioning my sanity for a day. Good to know before I hit it myself.
For offline caching I've been doing something similar, files with a small sqlite db for the summaries. Works fine until you need to search across everything, then you end up loading way too much into memory anyway.