报错: A value of type 'Widget' can't be returned from the method 'of' because it has a return type of 'SharedDataWidget'
➜ ~ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.7.0, on macOS 13.1 22C65 darwin-x64, locale
en-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version
31.0.0-rc4)
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.3)
[✓] IntelliJ IDEA Ultimate Edition (version 2020.3)
[✓] VS Code (version 1.75.0)
[✓] Connected device (3 available)
[✓] HTTP Host Availability
//定义一个便捷方法,方便子树中的widget获取共享数据 static ShareDataWidget of(BuildContext context) { //return context.dependOnInheritedWidgetOfExactType();
return context.getElementForInheritedWidgetOfExactType().widget;
}
报错: A value of type 'Widget' can't be returned from the method 'of' because it has a return type of 'SharedDataWidget'
➜ ~ flutter doctor Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.7.0, on macOS 13.1 22C65 darwin-x64, locale en-CN) [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0-rc4) [✓] Xcode - develop for iOS and macOS (Xcode 14.2) [✓] Chrome - develop for the web [✓] Android Studio (version 2021.3) [✓] IntelliJ IDEA Ultimate Edition (version 2020.3) [✓] VS Code (version 1.75.0) [✓] Connected device (3 available) [✓] HTTP Host Availability