How To Define an Interface in Dart

Dart defines implicit interfaces. What does this mean?

In your app you’d have:

class Session {
  authenticate() { // impl }


abstract class Session {

And for example in tests:

class MockSession implements Session {
  authenticate() { // mock impl }

No need to define a separate interface, just use regular or abstract classes!

Want to know EVERYTHING about Dart constructors? Check out Deconstructing Dart Constructors!

Need professional help with Flutter?

Describe your project in detail and include your e-mail and budget.