skip to Main Content

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…

VIEW QUESTION

Flutter – GestureDetector – onTap: widget.press(), – final Function press;- Navigator.of(context).push();

This is my first page (RecomendsPlants) and I want to move to another page called (DetailsScreen) RecomendsPlants: // ignore_for_file: prefer_const_constructors import 'package:flutter/material.dart'; import 'package:mr_plants_store/constants.dart'; import 'package:mr_plants_store/screens/details/details_screen.dart'; class RecomendsPlants extends StatefulWidget { const RecomendsPlants({super.key}); @override State createState() => _RecomendsPlantsState(); } class…

VIEW QUESTION
Back To Top
Search