gpt4 book ai didi

flutter - InkWell 小部件需要 Material 小部件祖先

转载 作者:IT王子 更新时间:2023-10-29 07:11:13 26 4
gpt4 key购买 nike

我在 Row 中添加 InkWell 作为 Widget,但它抛出了一个错误:

flutter: ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
flutter: The following assertion was thrown building InkWell(gestures: [tap], clipped to BoxShape.rectangle,
flutter: dirty, state: _InkResponseState<InkResponse>#0e6c5):
flutter: No Material widget found.
flutter: InkWell widgets require a Material widget ancestor.

这是我的代码:

Container(
color: Colors.red,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
InkWell(
onTap: (){
//Forgot password Tapped
},
child: Text(Constants.forgotPassword),),
],
),

最佳答案

InkWell 类将始终与 Material 类一起工作

请尝试下面的代码。

代码:用 Material 类包装 InkWell 类

  Material(
child: InkWell(
onTap: (){
//Forgot password Tapped
},
child: Text(Constants.forgotPassword),),
),

谢谢

关于flutter - InkWell 小部件需要 Material 小部件祖先,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56679076/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com