Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 736 Vote(s) - 3.53 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error: The method 'inheritFromWidgetOfExactType' isn't defined for the class 'BuildContext'

#1
Today when I compile my flutter project, it shows this error:


This will generate a JSON format file containing all messages that
need to be translated.
../../../.pub-cache/hosted/pub.flutter-io.cn/fish_redux-0.3.4/lib/src/redux_component/page.dart:208:17: Error: The method 'inheritFromWidgetOfExactType' isn't defined for the class 'BuildContext'.
- 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('../../../apps/flutter/packages/flutter/lib/src/widgets/framework.dart').
Try correcting the name to the name of an existing method, or defining a method named 'inheritFromWidgetOfExactType'.
context.inheritFromWidgetOfExactType(PageProvider);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../../../.pub-cache/hosted/pub.flutter-io.cn/pull_to_refresh-1.6.3/lib/src/smart_refresher.dart:273:21: Error: The method 'ancestorWidgetOfExactType' isn't defined for the class 'BuildContext'.
- 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('../../../apps/flutter/packages/flutter/lib/src/widgets/framework.dart').
Try correcting the name to the name of an existing method, or defining a method named 'ancestorWidgetOfExactType'.
return context?.ancestorWidgetOfExactType(SmartRefresher);
^^^^^^^^^^^^^^^^^^^^^^^^^
../../../.pub-cache/hosted/pub.flutter-io.cn/pull_to_refresh-1.6.3/lib/src/smart_refresher.dart:277:21: Error: The method 'ancestorStateOfType' isn't defined for the class 'BuildContext'.
- 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('../../../apps/flutter/packages/flutter/lib/src/widgets/framework.dart').
Try correcting the name to the name of an existing method, or defining a method named 'ancestorStateOfType'.
return context?.ancestorStateOfType(TypeMatcher<SmartRefresherState>());
^^^^^^^^^^^^^^^^^^^
../../../.pub-cache/hosted/pub.flutter-io.cn/pull_to_refresh-1.6.3/lib/src/smart_refresher.dart:1003:20: Error: The method 'inheritFromWidgetOfExactType' isn't defined for the class 'BuildContext'.
- 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('../../../apps/flutter/packages/flutter/lib/src/widgets/framework.dart').
Try correcting the name to the name of an existing method, or defining a method named 'inheritFromWidgetOfExactType'.
return context.inheritFromWidgetOfExactType(RefreshConfiguration);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../../../.pub-cache/hosted/pub.flutter-io.cn/chewie-0.9.10/lib/src/chewie_player.dart:276:17: Error: The method 'inheritFromWidgetOfExactType' isn't defined for the class 'BuildContext'.
- 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('../../../apps/flutter/packages/flutter/lib/src/widgets/framework.dart').
Try correcting the name to the name of an existing method, or defining a method named 'inheritFromWidgetOfExactType'.
context.inheritFromWidgetOfExactType(_ChewieControllerProvider)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../../../.pub-cache/hosted/pub.flutter-io.cn/chewie_audio-1.0.0+1/lib/src/chewie_player.dart:101:17: Error: The method 'inheritFromWidgetOfExactType' isn't defined for the class 'BuildContext'.
- 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('../../../apps/flutter/packages/flutter/lib/src/widgets/framework.dart').
Try correcting the name to the name of an existing method, or defining a method named 'inheritFromWidgetOfExactType'.
context.inheritFromWidgetOfExactType(_ChewieAudioControllerProvider)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^


I am using flutter master channel, this is the flutter doctor:


[✓] Flutter (Channel master, 1.26.0-2.0.pre.366, on Mac OS X 10.15.7 19H114 darwin-x64, locale en-CN)
• Flutter version 1.26.0-2.0.pre.366 at /Users/dolphin/apps/flutter
• Framework revision b7f6d9bcb2 (24 hours ago), 2021-01-15 07:44:03 -0500
• Engine revision 69a7538a90
• Dart version 2.12.0 (build 2.12.0-227.0.dev)
• Pub download mirror

[To see links please register here]

• Flutter download mirror

[To see links please register here]


[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at /Users/dolphin/Library/Android/sdk
• Platform android-30, build-tools 30.0.2
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.3, Build version 12C33
• CocoaPods version 1.10.0

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨

[To see links please register here]

• Dart plugin can be installed from:
🔨

[To see links please register here]

• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] IntelliJ IDEA Community Edition (version 2020.3.1)
• IntelliJ at /Applications/IntelliJ IDEA CE.app
• Flutter plugin can be installed from:
🔨

[To see links please register here]

• Dart plugin can be installed from:
🔨

[To see links please register here]


[✓] IntelliJ IDEA Ultimate Edition (version 2019.2.2)
• IntelliJ at /Users/dolphin/Applications/JetBrains Toolbox/IntelliJ IDEA Ultimate.app
• Flutter plugin can be installed from:
🔨

[To see links please register here]

• Dart plugin can be installed from:
🔨

[To see links please register here]


[✓] VS Code (version 1.52.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.18.1

[✓] Connected device (3 available)
• sdk gphone x86 arm (mobile) • emulator-5554 • android-x86 • Android 11 (API 30) (emulator)
• macOS (desktop) • macos • darwin-x64 • Mac OS X 10.15.7 19H114 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 87.0.4280.141
! Error: xiaoqiang 的 iPhone is not connected. Xcode will continue when xiaoqiang 的 iPhone is connected. (code
-13)

• No issues found!
(base)



after upgrade to flutter 2.0.1, shows this error again:



~/Documents/GitHub/cruise-open on  feature/channel! ⌚ 15:01:43
$ ~/apps/flutter/bin/flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.0.1, on Mac OS X 10.15.7 19H114 darwin-x64, locale en-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] IntelliJ IDEA Community Edition (version 2020.3.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2019.2.2)
[✓] VS Code (version 1.53.2)
[✓] Connected device (3 available)
! Error: xiaoqiang 的 iPhone is not connected. Xcode will continue when xiaoqiang 的 iPhone is connected. (code
-13)

• No issues found!
(base)




Reply

#2
For me was because I was using an old version of my dependencies. Check pub.dev to see if has a new version of your packages!
Reply

#3
This often happened when working with Dev and master channels, the best monthly picks of master that flutter consider more stable is channel Beta

flutter channel beta

[Flutter build release channels][1]
> We will branch from master for a new beta release at the beginning of
> the month, usually the first Monday. This will include a branch for
> Dart, the Engine and the Framework. This branch will then be
> "stabilized" for the next couple of weeks, meaning we will accept
> cherrypick requests for high impact issues. As we near the end of the
> month and the next beta branch, we will likely reduce the number of
> cherrypicks we are willing to do. Once a quarter, the beta branch will
> live on to become the next stable branch, as detailed below.


[1]:

[To see links please register here]

Reply

#4
### This error is caused by **[inheritFromWidgetOfExactType][1]** method.

This method is deprecated . Use **[dependOnInheritedWidgetOfExactType][1]** instead.

**Your project simply contains it**

### First solution :
Go back to version `1.26.0-8.0` manually or use this command :

flutter downgrade

### Second solution:
Switch to the beta channel

flutter channel beta

> If you don't have beta channel yet , you need to add `flutter upgrade`

### Third solution:
Update your project

Find **[inheritFromWidgetOfExactType][1]** method in your code and adapt it with **[dependOnInheritedWidgetOfExactType][2]**.

**Example of a replacement**:

**Before :** with [InheritFromWidgetOfExactType][1]

static Name of(BuildContext context) {
return context.inheritFromWidgetOfExactType(Name); //before
}

**Now** with [dependOnInheritedWidgetOfExactType ][2] (Recommanded)

static Name of(BuildContext context) {
return context.dependOnInheritedWidgetOfExactType<Name>(); //after
}

> Now instead of taking a `Type` as argument, **The method is generic .**
> Brief `<...>()` instead of `(...)`

The error may also be caused by a package you have imported :

**Solution:**
Check if this package has a new update

> **In fact,** this method has been depreciated since version 1.12.1 of flutter . But until then, its use was possible but not recommended.
Since version 1.26.0-12.0.pre it is no longer used, which explains the errors.


[1]:

[To see links please register here]

[2]:

[To see links please register here]

Reply

#5
**Upd!**

With Flutter 2 release downgrading SDK is not the best workaround in longer term. The right thing to do is going through dependencies and updating them, you can use `flutter pub outdated` terminal command to highlight available updates - then change pubspec.yaml with newer versions and try running your app. It might happen that some dependencies won't have the updates or fixes for the breaking changes in Flutter SDK. In this case you'll be locked into using older Flutter (until the dependency is updated or you replace it with some other package).

**Orig**

Run `flutter downgrade`

Received same error right after upgrading. Switching from *Flutter 1.26.0-12.0.pre • channel dev* to the previous verion (*1.26.0-8.0.pre*) made the build work again

This is a quickfix in case you are not in a mood to go through dependencies in `pubspec.yaml` updating them to newer ones (hoping there're updates to null-safety) but just want to carry on from the place you left. Eventualy you'll have to go through all your packages/plugins and update/replace them with *nullsafe* versions.
Reply

#6
If you need run providerin flutter 1.26 you should run: flutter downgrade.

If you need run provider in flutter 2.0.0 + you should change:

pubspec.yaml

provider: ^ 2.0.1 to ^5.0.0

main.dart

Change builder for create



`return MultiProvider(
providers: [
ChangeNotifierProvider(create: (context) => YourProvider()),
],`
Reply

#7
This problem occurs when using `provider` version less than 4.0.0.

You can solve it by opening your `pubspec.yaml` file and changing your provider version to 4.0.0 or higher.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through