For information about using experimental flags as a Dart developer, see the experiment flags documentation.
Overview
Experimental flags allow new features to be:- Developed and tested while disabled by default
- Gradually rolled out to users through beta releases
- Enabled by default once stable
- Retired after proven stable in production
Flag Definition
All experimental flags are defined in:- Flag names and descriptions
- SDK version requirements
- Default enabled/disabled status
- Expiration status
Feature Lifecycle
The typical lifecycle of an experimental feature spans multiple SDK versions:Development phase (Version n-1)
- Feature is developed behind a flag
- Flag is disabled by default
- Usually made public in beta 1 of version n-1
- Users can enable with
--enable-experiment=feature-name
Default enabled (Version n)
- Feature flag is enabled by default in beta 1 of version n
- Feature is still technically “experimental” but available to all
- Monitor for issues and user feedback
Stabilization (Version n)
- Feature runs in production for a full release cycle (~3 months)
- Must not cause significant issues
- Considered stable if feedback is positive
Timeline Example
Here’s a concrete example for a hypothetical feature:Development timelines vary. Some features span multiple versions, while others complete within a single release cycle and only appear in dev releases.
When to Retire Flags
Retire an experimental flag when:- ✅ Feature has been enabled by default for a full release cycle
- ✅ At least ~3 months have passed in stable
- ✅ No significant issues have been reported
- ✅ User feedback is positive
Flag Retirement Process
Clean up test usage
Remove or update tests that use the experimental flag:Tests should work without the flag since it’s enabled by default.
Clean up non-test code
Ensure SDK code doesn’t rely on checking the experimental flag:Remove conditional logic based on the flag.
Common Flag Patterns
Checking Flag Status in Code
During development, you may need to check if a flag is enabled:Test Annotations
Tests may require specific experiments:Finding Flag Usage
Useful commands for finding flag references:Exceptions and Special Cases
Short Development Cycles
Some features complete development quickly:- Development happens entirely in dev releases
- Never available in beta or stable with flag
- Enabled by default immediately upon completion
- Can be retired in the next release
Extended Development
Large features may take multiple releases:- Null safety took several versions to complete
- Flag may exist across many SDK versions
- Multiple beta cycles for user feedback
- Extended stabilization period
Deprioritized Features
If feature development is paused:- Keep flag disabled by default
- Don’t retire until development resumes and completes
- Document the status in the YAML file
Best Practices
Document thoroughly
Add clear comments in
experimental_features.yaml about the feature’s purpose and statusTest both states
During development, test with flag both enabled and disabled
Clean as you go
Remove flag dependencies during retirement, don’t accumulate technical debt
Coordinate releases
Work with EngProd team to align flag retirement with release milestones
Resources
- experimental_features.yaml - Flag definitions
- Public experiment docs - User-facing documentation
- Language evolution process - How features are designed