Dart
Native Regex since v1.0๐ฏ Leading underscore = private; everything else is fair game. Catches classes, mixins, enums, and top-level fns.
.dart What gets detected
The public surface spec-sync tracks for Dart.
- Top-level class / abstract class / mixin / enum / extension / typedef
- Top-level functions and return-typed variables (no _ prefix)
- const / final declarations (no _ prefix)
Detection rules
Public types (no _ prefix)
Matches class, abstract class, mixin, enum, extension, typedef declarations whose name starts with an uppercase letter (Dart convention for types).
class AuthService {}
abstract class BaseController {}
mixin LoggerMixin {}
enum AuthStatus { active, expired }
extension StringExt on String {}
typedef AuthCallback = void Function(String); const and final declarations
Top-level const and final declarations without _ prefix are captured.
const defaultTtl = 3600;
final String apiVersion = '1.0';
const int maxRetries = 3; Top-level functions and typed variables
Functions with explicit return types (Future, Stream, void, int, etc.) are captured. Identifiers starting with _ are private and excluded.
Future<String> fetchData() async {}
Stream<int> countUp() async* {}
void doNothing() {}
void _privateHelper() {} // excluded
const _secret = 'hidden'; // excluded Example: spec & source
The *.spec.md contract on the left,
the Dart source it documents on the right. spec-sync matches the two.
Spec (*.spec.md)
---
module: auth
version: 1
status: stable
files:
- lib/src/auth_service.dart
---
## Purpose
Flutter/Dart auth service.
## Public API
| Symbol | Kind | Description |
|--------|------|-------------|
| `AuthService` | class | Main auth class |
| `AuthCallback` | typedef | Auth callback type |
| `defaultTtl` | const | Default TTL in seconds |
| `fetchData` | Future<String> | Fetches auth data |
## Change Log
| Date | Change |
|------|--------|
| 2026-01-01 | Initial | Source
class AuthService {
final String apiKey;
AuthService(this.apiKey);
Future<bool> validate(String token) async {
return token.isNotEmpty;
}
}
typedef AuthCallback = void Function(String token);
const defaultTtl = 3600;
final String apiVersion = '1.0';
Future<String> fetchData() async => 'data';
void _internalHelper() {} // private, excluded Test-file patterns
Files matching these are excluded from the detected surface.
| Pattern | Explanation |
|---|---|
**/*_test.dart | Dart test files: auto-excluded |
Caveats
- Library-level directives (export 'file.dart') are not parsed. Only in-file declarations are captured.
- Late variables (late final ...) may not be captured depending on the return-type regex match.
- Dart extension names are captured, but extension members are not individually listed.
- Generated code (*.g.dart files from build_runner) are included if present in source directories.