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
It happens because of the old cache. Just clean the cache with the following command
flutter clean cache
I just had the same issue. It looks like I changed a flutter lib file by mistake.
To fix this, without reinstalling Flutter SDK:
git status
modified: packages/flutter/lib/src/widgets/basic.dart
git checkout FILE_PATH
(ex: git checkout packages/flutter/lib/src/widgets/basic.dart
)Clean the project cache by running
flutter clean cache
Then invalidate caches / restart Android Studio or VS Code.
Try Restarting your Analysis Dart Server.
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),
),
);
}
}