Flutter Compiling Debugging Error With Gradle - flutter

Recently i am want running some old app from another open source but when trying to compile with the same SDK with pubspec.yaml but having this kind problem
., [12/12/2022 11:37 PM]
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_redux-0.6.0/lib/flutter_redux.dart:77:19: Error: The method 'inheritFromWidgetOfExactType' isn't defined for the class 'BuildContext'.
- 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/framework.dart').
., [12/12/2022 11:37 PM]
Try correcting the name to the name of an existing method, or defining a method named 'inheritFromWidgetOfExactType'.
? context.inheritFromWidgetOfExactType(type)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_redux-0.6.0/lib/flutter_redux.dart:79:14: Error: The method 'ancestorInheritedElementForWidgetOfExactType' isn't defined for the class 'BuildContext'.
., [12/12/2022 11:37 PM]
- 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/framework.dart').
package:flutter/…/widgets/framework.dart:1
Try correcting the name to the name of an existing method, or defining a method named 'ancestorInheritedElementForWidgetOfExactType'.
.ancestorInheritedElementForWidgetOfExactType(type)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_circular_chart-0.1.0/lib/src/animated_circular_chart.dart:122:10: Error: The method 'ancestorStateOfType' isn't defined for the class 'BuildContext'.
- 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/framework.dart').
., [12/12/2022 11:38 PM]
* Where:
Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 991
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\src\flutter\bin\flutter.bat'' finished with non-zero exit value 1
., [12/12/2022 11:38 PM]
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 7m 25s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
I am still confuse what the solution is can you guys help? thank you for your guys help and advance God bless you all!

Your package flutter_redux-0.6.0 is three years old!
It does not work with the current Flutter version any more.
Use version 0.10.0

This is because the Flutter API changed slightly.
Now instead of using inheritFromWidgetOfExactType you have to use dependOnInheritedWidgetOfExactType
dependOnInheritedWidgetOfExactType takes Type as a generic.
From this:
final widget = context.inheritFromWidgetOfExactType(MyInheritedWidget) as MyInheritedWidget;
Migrated to:
final widget = context.dependOnInheritedWidgetOfExactType<MyInheritedWidget>();

Related

Flutter - Error Compiling project without changes

I am facing an issue in flutter for a couple of days
before I close Android Studio everything was working fine with no errors so far, next day I started it with no changes, and it shows me an error message and cannot compile while there is no errors in my code or in anything
../../AppData/Local/Pub/Cache/hosted/pub.dev/flutter_platform_widgets-1.20.0/lib/src/platform_dialog_action.dart:171:14:
Error: The method 'FlatButton' isn't defined for the class
'PlatformDialogAction'.
'PlatformDialogAction' is from 'package:flutter_platform_widgets/src/platform_dialog_action.dart'
('../../AppData/Local/Pub/Cache/hosted/pub.dev/flutter_platform_widgets-1.20.0/lib/src/platform_dialog_action.dart').
Try correcting the name to the name of an existing method, or defining
a method named 'FlatButton'.
return FlatButton(
^^^^^^^^^^ ../../AppData/Local/Pub/Cache/hosted/pub.dev/flutter_platform_widgets-1.20.0/lib/src/platform_button.dart:269:14:
Error: The method 'FlatButton' isn't defined for the class
'PlatformButton'.
'PlatformButton' is from 'package:flutter_platform_widgets/src/platform_button.dart'
('../../AppData/Local/Pub/Cache/hosted/pub.dev/flutter_platform_widgets-1.20.0/lib/src/platform_button.dart').
Try correcting the name to the name of an existing method, or defining
a method named 'FlatButton'.
return FlatButton(
^^^^^^^^^^ ../../AppData/Local/Pub/Cache/hosted/pub.dev/flutter_platform_widgets-1.20.0/lib/src/platform_button.dart:302:12:
Error: The method 'RaisedButton' isn't defined for the class
'PlatformButton'.
'PlatformButton' is from 'package:flutter_platform_widgets/src/platform_button.dart'
('../../AppData/Local/Pub/Cache/hosted/pub.dev/flutter_platform_widgets-1.20.0/lib/src/platform_button.dart').
Try correcting the name to the name of an existing method, or defining
a method named 'RaisedButton'.
return RaisedButton(
^^^^^^^^^^^^ Target kernel_snapshot failed: Exception
FAILURE: Build failed with an exception.
Where: Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line:
1151
What went wrong: Execution failed for task ':app:compileFlutterBuildDebug'.
Process 'command 'C:\src\flutter\bin\flutter.bat'' finished with non-zero exit value 1
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 10s Exception: Gradle task assembleDebug failed with
exit code 1
I tried to restart, search, and made everything but then nothing worked for me
Does anybody have an idea why is that happening?
thanks in advance

I used Carousel_Slider package in my flutter app and faced an issue?

I used Carousel_Slider package to build an image slider for my flutter app and I copied the parts of the code that I needed .SO after runnig the app I faced an issue that says ...
: Error: The value 'null' can't be assigned to a variable of type 'List' because 'List' is not nullable.
carousel_slider.dart:59
'List' is from 'dart:core'.
'Widget' is from 'package:flutter/src/widgets/framework.dart' ('../../Documents/flutter/packages/flutter/lib/src/widgets/framework.dart').
framework.dart:1
: items = null,
This is the whole DEBUG CONSOLE..
I used Carousel_Slider package to build an image slider for my flutter app and I copied the parts of the code that I needed .SO after runnig the app I faced an issue that says ...
: Error: The value 'null' can't be assigned to a variable of type 'List' because 'List' is not nullable.
carousel_slider.dart:59
'List' is from 'dart:core'.
'Widget' is from 'package:flutter/src/widgets/framework.dart' ('../../Documents/flutter/packages/flutter/lib/src/widgets/framework.dart').
framework.dart:1
: items = null,
Target kernel_snapshot failed: Exception
2
FAILURE: Build failed with an exception.
Where:
Script 'C:\Users\Islam\Documents\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1151
What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
Process 'command 'C:\Users\Islam\Documents\flutter\bin\flutter.bat'' finished with non-zero exit value 1
Try:
Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 3s
Exception: Gradle task assembleDebug failed with exit code 1
based on error logs ,
the List that you are giving in CarouselSlider Widget is null,
print your list in build to check what is the value of List that used in CarouselSlider.

Flutter run and build issue

The app was working fine but suddenlly its start showing the error when try to run or build
lib/main.dart:1
: Error: The getter 'mounted' isn't defined for the class 'BuildContext'.
../…/lib/fluttertoast.dart:154
'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('../../../flutter/packages/flutter/lib/src/widgets/framework.dart').
package:flutter/…/widgets/framework.dart:1
Try correcting the name to the name of an existing getter, or defining a getter or field named 'mounted'.
if (context?.mounted != true) {
^^^^^^^
2
FAILURE: Build failed with an exception.
Where:
Script '/Users/me/Documents/flutter/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 1159
What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
Process 'command '/Users/me/Documents/flutter/flutter/bin/flutter'' finished with non-zero exit value 1
I believe there may be other ways to solve it, but I solved it by updating flutter with flutter upgrade

Flutter Run : FAILURE Build failed with an exception

Please help me. Since I cloned this project from git I always get the following error message
../../../AppData/Local/Pub/Cache/hosted/pub.dev/flutter_math_fork-0.5.0/lib/src/encoder/tex/functions/frac.dart:113:37: Error: The getter 'optionsDiff' isn't defined for the class 'GreenNode'.
- 'GreenNode' is from 'package:flutter_math_fork/src/ast/syntax_tree.dart' ('../../../AppData/Local/Pub/Cache/hosted/pub.dev/flutter_math_fork-0.5.0/lib/src/ast/syntax_tree.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'optionsDiff'.
final remainingOptions = node.optionsDiff.removeStyle();
^^^^^^^^^^^
../../../AppData/Local/Pub/Cache/hosted/pub.dev/flutter_math_fork-0.5.0/lib/src/encoder/tex/functions/frac.dart:138:37: Error: The getter 'optionsDiff' isn't defined for the class 'GreenNode'.
- 'GreenNode' is from 'package:flutter_math_fork/src/ast/syntax_tree.dart' ('../../../AppData/Local/Pub/Cache/hosted/pub.dev/flutter_math_fork-0.5.0/lib/src/ast/syntax_tree.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'optionsDiff'.
final remainingOptions = node.optionsDiff.removeStyle();
^^^^^^^^^^^
Target kernel_snapshot failed: Exception
FAILURE: Build failed with an exception.
* Where:
Script 'C:\SRC\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1151
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDevDebug'.
> Process 'command 'C:\SRC\flutter\bin\flutter.bat'' finished with non-zero exit value 1
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 8s
Running Gradle task 'assembleDebug'... 9.6s
Exception: Gradle task assembleDebug failed with exit code 1
I have tried
flutter pub get
flutter clean
But still, get the error message above. I am getting error messages only in this project. if I do flutter run in another project it can run without problem.

I built an app in flutter but during run time i get A secondary container isnt defined for ColorScheme error

Launching lib\main.dart on SOV36 in debug mode...
lib\main.dart:1
: Error: The getter 'secondaryContainer' isn't defined for the class 'ColorScheme'.
../…/pointers/marker_pointer_renderer.dart:631
'ColorScheme' is from 'package:flutter/src/material/color_scheme.dart' ('../flutter/packages/flutter/lib/src/material/color_scheme.dart').
package:flutter/…/material/color_scheme.dart:1
Try correcting the name to the name of an existing getter, or defining a getter or field named 'secondaryContainer'.
_themeData.colorScheme.secondaryContainer.withOpacity(0.8)
^^^^^^^^^^^^^^^^^^
: Error: The getter 'secondaryContainer' isn't defined for the class 'ColorScheme'.
../…/pointers/marker_pointer_renderer.dart:642
'ColorScheme' is from 'package:flutter/src/material/color_scheme.dart' ('../flutter/packages/flutter/lib/src/material/color_scheme.dart').
package:flutter/…/material/color_scheme.dart:1
Try correcting the name to the name of an existing getter, or defining a getter or field named 'secondaryContainer'.
_themeData.colorScheme.secondaryContainer.withOpacity(0.12)
^^^^^^^^^^^^^^^^^^
: Error: The getter 'secondaryContainer' isn't defined for the class 'ColorScheme'.
../…/pointers/range_pointer_renderer.dart:567
'ColorScheme' is from 'package:flutter/src/material/color_scheme.dart' ('../flutter/packages/flutter/lib/src/material/color_scheme.dart').
package:flutter/…/material/color_scheme.dart:1
Try correcting the name to the name of an existing getter, or defining a getter or field named 'secondaryContainer'.
_themeData.colorScheme.secondaryContainer.withOpacity(0.8)
^^^^^^^^^^^^^^^^^^
2
FAILURE: Build failed with an exception.
Where:
Script 'C:\Users\JONAH\Documents\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1070
What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
Process 'command 'C:\Users\JONAH\Documents\flutter\bin\flutter.bat'' finished with non-zero exit value 1
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Try upgrade flutter.
flutter upgrade
flutter pub upgrade