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

How to navigate inside initState() in Flutter

@override void initState() { final Future<bool> is_initialized = IsInitialized(); if (is_initialized == false) { GenerateDefaultPreferences(); Navigator.push(context, MaterialPageRoute(builder: (context) => LanguageSelection())); //? } else { SynchronizeDLIfSet(); } } This is in my stateless widget. How can I navigate inside an initState()…

VIEW QUESTION

Flutter Error on running the application, can you help me?

I'm new to flutter development, at starting everything was well and good, but now everytime i run apy app i'm getting the following error. Please show me some ways to fix it. C:/Users/Admin/AppData/Local/Pub/Cache/hosted/pub.dev/material_color_utilities-0.8.0/lib/palettes/tonal_palette.dart:164:30: Error: The argument type 'double?' can't be…

VIEW QUESTION

Flutter – Missing Statechange in BlocListener (Cubit, initial Load)

I'm refactoring some of my blocs down to cubits and I'm struggling with an unexpected behavior. Widget @override Widget build(BuildContext context) { return BlocProvider( create: (context) => injector.get<DocumentListCubit>()..load(), child: BlocConsumer<DocumentListCubit, DocumentListState2>( listener: (context, state) { context.read<GlobalBusyIndicatorCubit>().busy = state.phase == DocumentListState2Enum.loading;…

VIEW QUESTION
Back To Top
Search