Skip to main content

Language rules

Use ZetaStatelessWidget or ZetaStatefulWidget

All components extend ZetaStatelessWidget or ZetaStatefulWidget — never plain StatelessWidget or StatefulWidget. These base classes add the rounded property and wire it to the inherited ZetaProvider, giving every component consistent shape behaviour for free.

foo.dart
// ✅ Good
class ZetaFoo extends ZetaStatelessWidget {
const ZetaFoo({super.key, super.rounded});


Widget build(BuildContext context) { ... }
}

// ❌ Bad — plain StatelessWidget, loses rounded and Zeta wiring
class ZetaFoo extends StatelessWidget {
const ZetaFoo({super.key});


Widget build(BuildContext context) { ... }
}

Use Dart — no dynamic

All files run under dart analyze with strict settings (implicit-casts: false, implicit-dynamic: false). dynamic defeats static analysis the same way any does in TypeScript — it silences errors that will become runtime crashes.

SituationUse instead
Unknown external dataObject? — forces a null-and-type check
Callback with unknown returnValueChanged<T>
Unconstrained generic<T extends Widget>
foo.dart
// ❌ Bad
void handleTap(dynamic event) { ... }
final value = json['key']; // dynamic

// ✅ Good
void handleTap(TapUpDetails details) { ... }
final value = json['key'] as String?;

Type everything explicitly

Every constructor parameter, field, and method return type must be written out. Do not rely on var or inference at the API boundary:

foo.dart
// ✅ Good
class ZetaFoo extends ZetaStatelessWidget {
const ZetaFoo({
super.key,
super.rounded,
required this.label,
this.flavor = ZetaWidgetStatus.info,
this.onTap,
});

final String label;
final ZetaWidgetStatus flavor;
final VoidCallback? onTap;
}

// ❌ Bad — missing types
class ZetaFoo extends ZetaStatelessWidget {
const ZetaFoo({super.key, required this.label, this.onTap});

final label;
final onTap;
}

Organize imports

Follow Dart import ordering and use show to make the surface of an import explicit where it reduces ambiguity:

foo.dart
// ✅ Good — grouped: dart → flutter → package → relative
import 'dart:ui';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

import 'package:zeta_flutter/zeta_flutter.dart' show ZetaColors, ZetaSpacing;

import '../tokens/zeta_color_scheme.dart';

Avoid wildcard imports from internal packages — they expose private symbols and make dependency tracking harder.