如何在颤动中的两个小部件之间伸展上下文?
我有两个不同的小部件。我在另一个中间使用的第二个小部件。问题是我不了解如何将上下文扩展到下一个小部件。 fіrst widget:
Widget _getRow({
required String name,
required String fullAddress,
required String id,
required ValueChanged<String> onTap,
}) {
return Material(
color: Colorz.white,
child: InkWell(
splashColor: Colorz.selectedListItemBG2,
child: BlocBuilder<AddressesBloc, AddressesState>(
buildWhen: (previous, current) =>
current is AddressesRemoveItemState,
builder: (context, state) {
bool progress;
if (state is AddressesRemoveItemState && id == state.addressId) {
progress = state.isProgress;
} else {
progress = false;
}
return Stack(
children: [
progress
? Center(
child: Container(
color: Colorz.transparent30,
child: const PlatformProgressIndicator()),
)
: const EmptyWidget(),
_listItemColumn(
name: name,
fullAddress: fullAddress,
id: id
)
],
);
}),
onTap: () {},
),
);
}
second widget:
_listItemColumn({
required String name,
required String fullAddress,
required String id,
}) {
return Column(
children: [
Padding(
padding: const EdgeInsets.fromLTRB(
Margins.medium, Margins.tiny, Margins.tiny, Margins.small),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
children: [
),
Material(
color: Colorz.white,
child: InkWrapper(
splashColor: Colorz.lighterGray,
child: IconButton(
alignment: Alignment.center,
icon: SvgPicture.asset(
Img.listItemMenu,
),
onPressed: () {
/*nan*/
},
),
onTap: () {
BlocProvider.of<BottomSheetBloc>(context).add(
BottomSheetEventOpenRemoveAddress(
addressId: id ,
),);
},
),
),
],
),
),
],
);
}
When I use BlocProvider:
BlocProvider.of<BottomSheetBloc>(context).add(
BottomSheetEventOpenRemoveAddress(
addressId: id ,
),);
I have an error:
blocprovider.of()拨打不包含底部表格的上下文。
因此,我想利用建筑物发生的前一个小部件的上下文。有人知道该怎么做吗?
I have two different widget. The second widget I use in the middle of the other. The problem is that I don't understand how to extend the context to the next widget.
fіrst widget:
Widget _getRow({
required String name,
required String fullAddress,
required String id,
required ValueChanged<String> onTap,
}) {
return Material(
color: Colorz.white,
child: InkWell(
splashColor: Colorz.selectedListItemBG2,
child: BlocBuilder<AddressesBloc, AddressesState>(
buildWhen: (previous, current) =>
current is AddressesRemoveItemState,
builder: (context, state) {
bool progress;
if (state is AddressesRemoveItemState && id == state.addressId) {
progress = state.isProgress;
} else {
progress = false;
}
return Stack(
children: [
progress
? Center(
child: Container(
color: Colorz.transparent30,
child: const PlatformProgressIndicator()),
)
: const EmptyWidget(),
_listItemColumn(
name: name,
fullAddress: fullAddress,
id: id
)
],
);
}),
onTap: () {},
),
);
}
second widget:
_listItemColumn({
required String name,
required String fullAddress,
required String id,
}) {
return Column(
children: [
Padding(
padding: const EdgeInsets.fromLTRB(
Margins.medium, Margins.tiny, Margins.tiny, Margins.small),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
children: [
),
Material(
color: Colorz.white,
child: InkWrapper(
splashColor: Colorz.lighterGray,
child: IconButton(
alignment: Alignment.center,
icon: SvgPicture.asset(
Img.listItemMenu,
),
onPressed: () {
/*nan*/
},
),
onTap: () {
BlocProvider.of<BottomSheetBloc>(context).add(
BottomSheetEventOpenRemoveAddress(
addressId: id ,
),);
},
),
),
],
),
),
],
);
}
When I use BlocProvider:
BlocProvider.of<BottomSheetBloc>(context).add(
BottomSheetEventOpenRemoveAddress(
addressId: id ,
),);
I have an error:
BlocProvider.of() called with a context that does not contain a BottomSheetBloc.
So I want to use the context of the previous widget where the building takes place. Does anyone know how to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论