Currently when you use the Refactor -> Extract Method option, it creates a method with root Widget item return-type. e.g:
Widget build(BuildContext context){
return Scaffold
body: Container(
child: Text('Hi'),
),
);
}
Now if you extract the Container it creates such a method for you:
Widget build(BuildContext context){
return Scaffold
body: _buildContainer(),
);
}
Container _buildContainer(){
return Container(
child: Text('Hi'),
);
}
The problem is that in many cases we wrap the root widget into another (for example in this scenario, in a ClipRRect, so it's better to have a generic Widget type as return-type:
Widget build(BuildContext context){
return Scaffold
body: _buildContainer(),
);
}
Widget _buildContainer(){
return Container(
child: Text('Hi'),
);
}
Currently when you use the
Refactor -> Extract Methodoption, it creates a method with root Widget item return-type. e.g:Now if you extract the
Containerit creates such a method for you:The problem is that in many cases we wrap the root widget into another (for example in this scenario, in a
ClipRRect, so it's better to have a genericWidgettype as return-type: