I ran flutter upgrade today, and now I am getting an error that says-
[dart] The named parameter 'child' isn't defined.
The project is newly created and the default code is untouched, but it still has the same Error:
In my case it happens when I name the widget with the same name of a flutter component, like so:
class OutlineButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
return OutlineButton(
child: Text('+R\$ 5'),
onPressed: () {},
borderSide: BorderSide(color: Colors.grey),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30.0),
),
);
}
}
You need to change the name of the created component with a different name, for example:
class CustomOutlineButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
return OutlineButton(
child: Text('+R\$ 5'),
onPressed: () {},
borderSide: BorderSide(color: Colors.grey),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30.0),
),
);
}
}
Clean the project cache by running
flutter clean cache
Then invalidate caches / restart Android Studio or VS Code.
Try Restarting your Analysis Dart Server.
click
on the Dart Analysis
tabClick
on the Restart icon.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With