waft-foundation
Flutter's foundation library, and the App every other framework crate runs on. It takes waft-embedder (the host traits and dart:ui's value types) and web-time (the current time on every target, a browser's included), and provides:
AppandAppCell. TheAppholds every Flutter object, the singletons, the timers, the microtasks and the async tasks; every framework call takes it as&mut App.AppCellowns it and runs the checkpoint, between turns, where the dropped objects are freed and the microtasks and tasks run.- The arena:
Ref<T>andHandle<T>. A constructor isnew. One that makes an arena object takes&mut Appand returns aRef; one that makes a plain value returns the value, and takes theApponly to read it.App::createis the arena call those constructors make. ARefkeeps its object as a Dart reference does; the object is freed at the checkpoint after its lastRefdrops. AHandleis theCopyid that keeps nothing: the method receiver (self: Handle<Self>), read throughapp.get/app.get_mut, and turned back into aRefwithupgradewhile something keeps the object, or withkeepwhere something is known to (it panics naming the object if nothing does). ARefand a bare handle of the same object compare equal. The erased form of a typedRefiserase/into_erased;AnyRefkeeps an object of any type;erased_handle!gives an erased type (Dart's abstract class used as a type) the items every erased type shares. Tree nodes are kept by the tree code (into_tree_node,release_tree_node). ChangeNotifier,Listenable,ValueListenable,ValueNotifier,Listener. A notifier is aChangeNotifierDatafield; a tear-off (Listener::handle_method) keeps nothing and is skipped once its receiver is freed;Listener::downgradegives a listener that removes itself.Entity<T>, GPUI's store for state an app writer owns, which is not where Flutter objects live.DateTime, in UTC or in the local time zone, which the app's platform gives (Platform::time_zone_offsetandtime_zone_name, the two calls Dart's natives make of the VM), so what makes a local value takes theApp; Dart's equivalent-year mapping and its probing for a wall time's offset are done here, over the offsets the platform answers, with no time zone database.SignedDuration, Dart'sDurationwhere it can be negative, such as a zone's offset west of UTC, is waft-embedder's, re-exported here.Timer,Completer,Task, keys,ObserverListand Flutter's foundation constants.- Debug tooling, in debug builds: the stale-read message names a freed object's type, creation site and checkpoint;
debug_live_objectslists what the arena holds, whichwaft_test::object_snapshot/assert_no_new_objectscount by type and creation site;debug_take_not_disposedanddebug_take_not_collectedreport Flutter's two leak kinds. "Not disposed" covers aChangeNotifierfrom its first listener,Ticker,AnimationController,CurvedAnimationandRestorationBucket, and not yet the gesture recognizers or the image types; "not collected" sees the types whosedisposecallsmark_disposedand skips tree nodes, which the hit-test path keeps legitimately after the tree releases them; neither sees a type with nodispose, such as a tween, which only a test'swaft_test::object_snapshot/assert_no_new_objectscatches;debug_take_skipped_tear_offsreports a listener whose receiver was freed without removing it. A creation site is the caller's line only for a constructor marked#[track_caller], and the constructor's own line otherwise.
An app writer needs four rules. Store a Ref for anything you keep — fields of your state and your widgets — and never free anything. Call dispose where Flutter does, for what your state created; it frees nothing, and the object stays readable while something keeps it. A closure you register on an object must not capture a Ref to that same object: capture the state's bare handle and read the field inside, or use a tear-off; breaking this leaks until dispose and does not crash. After an await or a timer, ask mounted before using a state or a BuildContext.
Every framework crate above it uses it: scheduler, gestures, services, painting, rendering, widgets and the kits. The porting rules for its types are in .agents/skills/porting-flutter/patterns/ownership.md and handle-receiver.md.