Built-in Annotations: override, deprecated
Signal intent to tools and teammates.
Built-in Annotations: override, deprecated is a free Dart Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Dart Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
What Annotations Are
An annotation is metadata you attach to code with an @ symbol. It does not run; it informs tools, the analyzer, and your teammates. 🏷️
The @ Syntax
You place an annotation on the line right before a declaration. The @ prefix tells Dart this token is metadata, not a normal expression.
@override
String toString() => 'Cat';Meet @override
The @override annotation says a method intentionally replaces one from a superclass or interface. It documents your intent clearly.
class Dog extends Animal {
@override
void speak() => print('Woof');
}Why @override Helps
If you misspell the method or its signature drifts, the analyzer warns you. So @override turns silent typos into early, visible errors.
Meet @deprecated
The @deprecated annotation marks an API as outdated. Code that uses it still works, but the analyzer shows a strike-through warning. ⚠️
@deprecated
void oldLogin() {}Deprecated With a Reason
Use @Deprecated with a message to guide callers toward the replacement. The text appears in tooltips and editor warnings.
@Deprecated('Use signIn() instead')
void login() {}Annotations Take Arguments
Some annotations are constructor calls, so they accept arguments in parentheses. The @Deprecated('...') form is one example you just saw.
Meet @pragma
The @pragma annotation passes hints to the Dart compiler or runtime. It is advanced, but good to recognize when you read library code.
@pragma('vm:entry-point')
void handler() {}Annotations Do Not Run
Remember: annotations are passive labels. They never execute on their own. Their value is read by tools, the analyzer, or code generators instead.
Where You Can Place Them
You can annotate classes, methods, fields, parameters, and more. Each annotation defines which targets it allows when it is declared.
@deprecated
class LegacyService {}Stacking Annotations
You may stack several annotations on one declaration, each on its own line. Order does not change behavior, so write them for readability.
@override
@deprecated
void render() {}Quick Check
Pick the annotation that flags a method as replacing a parent one.
Recap
You met three built-in annotations: @override for intent, @deprecated for warnings, and @pragma for compiler hints. All are passive metadata. 🎉
Frequently asked questions
Is the “Built-in Annotations: override, deprecated” lesson free?
Yes — the full text of “Built-in Annotations: override, deprecated” is free to read here on the web, and the Dart Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Dart Academy course, upgrade to CoddyKit PRO.
What will I learn in “Built-in Annotations: override, deprecated”?
Signal intent to tools and teammates. You practise Dart Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Dart Academy?
No prior experience is required. Dart Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Built-in Annotations: override, deprecated” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Dart Academy lesson?
Yes. Every Dart Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Built-in Annotations: override, deprecated
- Writing Custom Annotations
- Code Generation With build_runner
- json_serializable in Action