Closed
Description
Request to make extension methods behave like actual class member functions. Here is an example, calling type casting Center widget and calling the extension method calls Widget extension method instead of Center extension method. This will allow developers to add functionality to the library or framework without actually modifying the library's source code.
`
import 'package:flutter/material.dart';
void main() {
Widget widget = Center(child: Container(width: 50, height: 50, color: Colors.yellow,),);
widget.foo();
runApp(widget);
}
extension WidgetExtension on Widget {
void foo() {
print("Widget.foo");
}
}
extension CenterWidgetExtension on Center {
void foo() {
print("Center.foo");
child?.foo();
}
}
extension ContainerWidgetExtension on Container {
void foo() {
print("Container.foo");
child?.foo();
}
}
`