Flutter – Can't call onTap function
It always appears error below when I run the code. Could anyone give an advice? Thanks. Error: Not a constant expression. page.dart MyButton(text: 'Get Started',onTap: (){Navigator.pushNamed(context,'/menupage');},), button.dart class MyButton extends StatelessWidget {final String text;final void Function()? onTap; const MyButton({super.key,required this.text,required…