- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在推新 Route
在我的图库文件中添加到详细信息文件 Hero
动画片。一切都很好,但是当我调用 pop()
时在返回图库的详细信息文件中,我有一个 Provider
错误 :
flutter: ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
flutter: The following ProviderNotFoundException was thrown building GalleryThumbnail(dirty, state:
flutter: _GalleryThumbnailState#9dc96):
flutter: Error: Could not find the correct Provider<GalleryViewModel> above this GalleryThumbnail Widget
这是我的画廊文件:
@override
Widget build(BuildContext context) {
return MultiProvider(
providers: [
ChangeNotifierProvider.value(value: galleryViewModel),
ChangeNotifierProvider.value(value: galleryProvider)
],
child: Scaffold(
resizeToAvoidBottomInset: false,
body: Stack(
children: [
Consumer<GalleryViewModel>(
builder: (context, model, child) =>
galleryViewModel.assetsList.length != 0 ? gallery() : emptyGallery()),
...
}
Widget gallery() {
return Container(
padding: EdgeInsets.only(left: 5, right: 5, top: 5),
child: CupertinoScrollbar(
child: GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
crossAxisSpacing: 2,
mainAxisSpacing: 2,
childAspectRatio: 0.85,
),
itemCount: galleryViewModel.assetsList.length,
padding: EdgeInsets.only(bottom: Constants.navBarSize),
physics: BouncingScrollPhysics(),
shrinkWrap: true,
itemBuilder: (context, index) {
if(index >= galleryViewModel.assetsList.length-30) {
galleryViewModel.onLoadMore(index);
}
return _galleryItem(index);
},
),
),
);
}
Widget _galleryItem(int index) {
return Stack(
children: [
Consumer<GalleryProvider>(
builder: (context, model, child) {
return Container(
padding:
multipleSelection ? EdgeInsets.all(2) : EdgeInsets.all(0),
decoration: multipleSelection ? BoxDecoration(
borderRadius: BorderRadius.circular(20),
border: Border.all(color: Colors.transparent , width: 2)) : BoxDecoration(),
child: child,
);
},
Hero(
createRectTween: (Rect? begin, Rect? end) {
RectTween _rectTween =
RectTween(begin: begin, end: end);
return _rectTween;
},
tag: galleryViewModel.assetsList[index].id,
child:
child: GalleryThumbnail(
asset: galleryViewModel.assetsList[index],
onTap: (data) {
Navigator.push(context, MaterialPageRoute(builder: (context) {
return MediaEditorPage(
asset: galleryViewModel.assetsList[index],
bytes: data);
}));
},
),
...
}
当我在没有英雄或其他路线的情况下插入时,没有错误,我不知道为什么在英雄上方找不到提供者,我不会在导航器转换时通知任何提供者。
最佳答案
使用时Hero
小部件,似乎有一个 Context
问题。
这意味着当动画正在执行时,并且在目的地您正在调用 Provider.of<Model>(context)
,它不会找到正确的 Provider
.
您只需像使用 Navigator
那样做即可在你的例子中给出:
Hero(
createRectTween: (Rect? begin, Rect? end) {
RectTween _rectTween =
RectTween(begin: begin, end: end);
return _rectTween;
},
tag: galleryViewModel.assetsList[index].id,
child: ChangeNotifierProvider.value(
value: galleryViewModel,
child: GalleryThumbnail(
asset: galleryViewModel.assetsList[index],
size: size,
onLongPress: () {
if (!multipleSelection) {
multipleSelection = true;
galleryViewModel.selectedAssets.add(galleryViewModel.assetsList[index]);
galleryProvider.notify();
}
},
onTap: (data) {
Navigator.push(context, MaterialPageRoute(builder: (context) {
return MediaEditorPage(
asset: galleryViewModel.assetsList[index],
bytes: data);
}));
},
),
),
)
我已添加:
ChangeNotifierProvider.value(value: galleryViewModel)
包装
GalleryThumbnail
.
关于flutter - 无法使用英雄动画 Flutter 找到正确的 Provider<>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69238176/
正在复制的问题是,当sew呈现登录页面时,然后我们继续执行身份验证,现在将我们重定向到网站的仪表板,此时我们继续关闭会话,并且在之前的交互中生成的这些cookie没有被删除。这个问题是重复性的,并且一
我是 Flutter 的新手,目前正在研究 DI。 我正在使用 flutter_bloc 和 provider 包。 flutter_bloc 附带一个 RepositoryProvider,我现在问
我是 Flutter 的新手,目前正在研究 DI。 我正在使用 flutter_bloc 和 provider 包。 flutter_bloc 附带一个 RepositoryProvider,我现在问
我正在使用 Angular2 开发一个应用程序。 我正在尝试在我的应用程序中使用 Reactive Forms,但我遇到了一些错误: 第一个错误是关于 NgControl 的,如下所示: No pro
最近很多用户在使用电脑的时候发现了wmi provider host进程占用内存比较大,不知道这个进程到底是干什么的,能不能禁止,怎么禁止。下面来一起看看想想的介绍吧。 wmi provide
我的问题是: 当我在设计时不知道这些表达式的数量和类型时,如何将列表中的表达式拼接成一个引用? 在底部,我包含了类型提供程序的完整代码。 (我已经剥离了这个概念来证明这个问题。)我的问题出现在这些行:
我目前正在学习使用 Flutter 进行应用程序开发,并已开始学习 Provider 包。我遇到了一些困难并收到错误: “在此...小部件之上找不到正确的提供者” 我最终移动了 Provider 小部
我是 android 的新手,我正在学习如何使用 JavaMail API 发送电子邮件的教程,我已经正确添加了必要的 Jar,但我总是遇到无法解析 GmailSender 类上的符号提供程序,我尝试
我正在我的 Angular 应用程序中进行单元测试,我正在使用 TestBed 方法, 我正在测试组件,所以每个规范文件看起来像这样 import... describe('AppComponent'
enter image description here 代码:这是我的 index.js 文件 index.js import { Provider } from "react-redux"
Microsoft ASP.NET Universal Providers 1.1昨天与System.Web.Providers 1.2一起发布.在后面的 nuget 页面上声明:Legacy pac
在我的 Next js 项目中,我使用了 Next auth,其中 import {Provider} from 'next-auth/client' , 并包裹 在 _app.js 中。 但是,与此
当我在 View 模型中使用如下界面时 class MainViewModel @ViewModelInject constructor( private val trafficImagesR
更新 - 我实际上发现它是 Flutter Issue . 我有两个 Provider,一个是 EntriesProvider,另一个是 EntryProvider。我在创建条目时使用我的 Entry
function configure($provide, $injector) { $provide.provider("testservice", function () {
这真让我抓狂。我似乎无法弄清楚这有什么问题。 代码: public interface IMinutesCounter { void startTimer(); void stopTi
我在我的项目中玩 Dagger 2,然后我陷入了这个错误编译。-> Error:(18, 21) error: ....MyManager cannot be provided without an
我有一个 Resteasy 应用程序,它使用 Spring 并包含 ContainerRequestFilter 和 ContainerResponseFilter 实现,并用 @Provider 注
我正在尝试使用 Dagger2 设置一个新项目,我以前使用过 Dagger2,但现在我正在尝试自己从头开始设置它。我正在从我参与的 Kotlin 项目中获取示例,但无法像现在在 Kotlin 中一样为
我刚开始学习 dagger2,遇到了一个奇怪的问题,在我看来像是一个错误。这是模块: @Module public class SimpleModule { @Provides Coo
我是一名优秀的程序员,十分优秀!