What is Interface in DART
In this article, you will learn how to use interface in dart
Dart Interface
An interface defines how one may interact with an object. In interface you can
declare a abstract method (means you can declare body in it's sub class ),
basically it is used for solving the problem of multiple inheritance.
Syntax of interface
interface identifier interface name{
//.........Abstract Method.................//} e.g, interface
MyInterface{ AbstactMethod();} |
Example of interface
interface
Dartinterface{
MyInterface();
}
class
BasicInterface implements Dartinterface{
MyInterface(){
print("I am a inteface");
}
}
void
main(){
BasicInterface obj = new
BasicInterface();
obj.MyInterface();
} |
Output:

Example of default class for an interface
interface
Dartinterface default BasicInterface{
MyInterface();
Dartinterface();
}
class
BasicInterface implements Dartinterface{
MyInterface(){
print("I am a inteface");
}
}
void
main(){
//BasicInterface obj = new
BasicInterface();
Dartinterface obj = new
Dartinterface();
obj.MyInterface();
} |
Output:

Ask Your Question
Got a programming
related question? You may want to post your question here