why Error in @override flutter class? I am new to flutter. Please tell me what is my mistake? I use a class so that there is no code repetition, but it swears at @override Code below -
class Navigator extends StatelessWidget {
final String nameButton;
final String navigation;
const Navigator(this.nameButton, this.navigation)
@override
Widget build(BuildContext context) {
return Container(
width: 220,
height: 55,
child: ElevatedButton(onPressed: () {
context.go('/$navigation}');
}, child: Text(nameButton, style: TextStyle(fontSize: 23),),
style: ElevatedButton.styleFrom(shape: StadiumBorder(), primary: Colors.cyan),
),
);
}
}
error -
Const constructors can't have a body. Try removing either the 'const' keyword or the body.
A function body must be provided. Try adding a function body.
CodePudding user response:
Can you try like this? You need to remove const
Navigator(this.nameButton, this.navigation);