Miras Kairanov Miras Kairanov - 3 months ago 23
Dart Question

Dart strong mode: on casting implementation to abstract class implementation's are still visible and compiler is not throwing errors

My abstract class:

abstract class Animal {
void saySomething() {
debugPrint("I'm an animal");

My implementation class:

class Cow implements Animal {
int _mooCount = 0;

Cow action({
String sound,
int setCount,
int removeCount,
bool flushCount
}) {
if (setCount != null) {
this._mooCount = setCount;
if (sound != null) {
debugPrint(sound + ",count= " + _mooCount.toString());
} else {
return this;

void saySomething() {

How do i use it:

Animal myCow = new Cow();
myCow = myCow.action(setCount: 0).action(sound: "Moooooooo");

Intellij IDEA says:

The method 'action' isn't defined for the class 'Animal'

But everything compiles well in strong mode.


strong-mode: true

flutter output:

I/flutter ( 6325): Mooo
I/flutter ( 6325): Moooooooo,count= 1
I/flutter ( 6325): Auuuuuuuuuuuuuuu

Answer Source

As Vyacheslav Egorov said, strong mode has no influence on Dart VM at the moment.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download