Static Extension Members and Conflicts
Resolve clashes and add static helpers.
Static Extension Members and Conflicts is a free Dart Academy lesson on CoddyKit — lesson 3 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.
Two Helpers, Same Name
Import two extensions that both add a method called parse to String, and Dart no longer knows which one you meant.
Why Conflicts Happen
Extension members are not on the type itself, so two same-named methods are an ambiguity the compiler refuses to guess about.
Spot the Error
When this happens Dart reports an ambiguous extension and stops, rather than silently picking a winner for you.
"7".parse(); // error: ambiguous between two extensionsHide One on Import
Use hide on the import to drop one conflicting extension by name, leaving the other free to win the call.
import 'b.dart' hide NumberParsing;Or Show Only One
The mirror trick is show, which imports just the names you list and quietly excludes the rest.
import 'a.dart' show NumberParsing;Call It Explicitly
You can also be precise with explicit application: name the extension and pass the value in parentheses.
NumberParsing("7").parse();Add Static Members
Extensions can hold static members too. These belong to the extension name, not to the values you call methods on.
extension MathX on num {
static num clampLow(num x) => x < 0 ? 0 : x;
}Access Statics by Name
Call a static member through the extension name, just like a static on a class. The receiver value is not involved.
print(MathX.clampLow(-3)); // 0Statics Need a Name
Because you reach statics through the extension, an unnamed extension cannot expose them. Name it to use static members.
Members Versus Statics
Instance members use this and ride on a value; static members ignore the value and live on the extension itself.
Plan to Avoid Clashes
Give extensions clear, specific names and members. Good naming prevents most conflicts before show or hide is ever needed.
Quick Check
One conflict, one clean fix. Which works?
Recap: Statics and Conflicts
You can resolve clashing extensions with show, hide, or explicit calls, and add static members reached through the extension name. 🧩
Frequently asked questions
Is the “Static Extension Members and Conflicts” lesson free?
Yes — the full text of “Static Extension Members and Conflicts” 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 “Static Extension Members and Conflicts”?
Resolve clashes and add static helpers. 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 3 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Static Extension Members and Conflicts” 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
- Writing Your First Extension
- Extensions on Generics
- Static Extension Members and Conflicts
- Extension Types for Zero-Cost Wrappers