This post is about the data model behind my aquarium app: readings where a
blank field never turns into a zero, free ammonia worked out from pH and
temperature, one stored unit per parameter, and a local Drift database that
syncs to Supabase through an outbox. The app is
Aquarium - Log Tracker ,
a free iPhone logbook for water tests, written in Flutter. What it does for
fishkeepers is in the user-facing post ;
this one is the code.
Blank is not zero
A water test is a handful of numbers typed standing at a tank, often with wet
hands, and nobody tests everything every time. So the first real decision was
what an empty field means. The answer is nothing. There is no nullable value
column: a parameter you didn't test produces no row at all.
for ( final setting in settings ) { final text = _controllers [ setting . key ] ? . text . trim ( ) ?? '' ; // An untouched field produces no reading at all. Never zero. if ( text . isEmpty ) continue ;
final value = double . tryParse ( text .…