Hello I'm getting this error when I tried to run the app and its says that Closure call with mismatched arguments: function 'TasksList.build...'Since this is my first time using the provider, i don't know if it is due to the consumer or what...i will be very thankful if someone could help with this.
Here is the full error whic shows 2 exceptions:
======== Exception caught by foundation library ====================================================The following assertion was thrown while dispatching notifications for TaskData:setState() or markNeedsBuild() called during build.This _InheritedProviderScope<TaskData?> widget cannot be marked as needing to build because the framework is already in the process of building widgets. A widget can be marked as needing to be built during the build phase only if one of its ancestors is currently building. This exception is allowed because the framework builds parent widgets before children, which means a dirty descendant will always be built. Otherwise, the framework might not visit this widget during this build phase.The widget on which setState() or markNeedsBuild() was called was: _InheritedProviderScope<TaskData?> value: Instance of 'TaskData' listening to valueThe widget which was currently being built when the offending call was made was: TaskTile dirtyWhen the exception was thrown, this was the stack: #0 Element.markNeedsBuild.<anonymous closure> (package:flutter/src/widgets/framework.dart:4862:9)#1 Element.markNeedsBuild (package:flutter/src/widgets/framework.dart:4874:6)#2 _InheritedProviderScopeElement.markNeedsNotifyDependents (package:provider/src/inherited_provider.dart:577:5)#3 ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:403:24)======== Exception caught by widgets library =======================================================The following NoSuchMethodError was thrown building TaskTile(dirty):Closure call with mismatched arguments: function 'TasksList.build.<anonymous closure>.<anonymous closure>.<anonymous closure>'Receiver: Closure: (dynamic) => NullTried calling: TasksList.build.<anonymous closure>.<anonymous closure>.<anonymous closure>()Found: TasksList.build.<anonymous closure>.<anonymous closure>.<anonymous closure>(dynamic) => NullThe relevant error-causing widget was: TaskTile TaskTile:file:///D:/Development/VS%20Code%20flutter/todoey_app/lib/widgets/tasks_list.dart:15:20When the exception was thrown, this was the stack: #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:38:5)#1 _objectNoSuchMethod (dart:core-patch/object_patch.dart:85:9)#2 TaskTile.build (package:todoey_app/widgets/task_tile.dart:27:36)#3 StatelessElement.build (package:flutter/src/widgets/framework.dart:5367:49)#4 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5297:15)#5 Element.rebuild (package:flutter/src/widgets/framework.dart:5016:7)#6 StatelessElement.update (package:flutter/src/widgets/framework.dart:5373:5)#7 Element.updateChild (package:flutter/src/widgets/framework.dart:3685:15)#8 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6441:14)#9 Element.updateChild (package:flutter/src/widgets/framework.dart:3685:15)#10 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6441:14)#11 Element.updateChild (package:flutter/src/widgets/framework.dart:3685:15)#12 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5322:16)#13 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5462:11)
Here is the TaskList class code :
import 'package:flutter/material.dart';import 'package:provider/provider.dart';import 'package:todoey_app/widgets/task_tile.dart';import '../models/task_data.dart';class TasksList extends StatelessWidget { const TasksList({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Consumer<TaskData>( builder: (context, taskData, child) { return ListView.builder( itemBuilder: (context, index) { final task = taskData.tasks[index]; return TaskTile( taskTitle: task.name, isChecked: task.isDone, checkboxCallback: (checkboxState) { taskData.updateTask(task); }, longPressCallback: () { taskData.deleteTask(task); }, ); }, itemCount: taskData.taskCount, ); }, ); }}
Here is the TaskTile class code :
import 'package:flutter/material.dart';class TaskTile extends StatelessWidget { final bool isChecked; final String taskTitle; final Function checkboxCallback; final Function longPressCallback; TaskTile( {required this.isChecked, required this.taskTitle, required this.checkboxCallback, required this.longPressCallback}); @override Widget build(BuildContext context) { return ListTile( onLongPress: longPressCallback(), title: Text( taskTitle, style: TextStyle( decoration: isChecked ? TextDecoration.lineThrough : null), ), trailing: Checkbox( activeColor: Colors.lightBlueAccent, value: isChecked, onChanged: checkboxCallback(), ), ); }}
When i run my app it is giving me this error and i am unable to diagnose what the problem is.