flutter / flutter/flutter-intellij
Return generic Widget instead of specific widget during extract method
- Dominant language
- Java
- Stars
- 2k
- Forks
- 356
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 27
Description
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'),
);
}
```
Contributor guide
Assessment
This issue has not been assessed yet.