flutter - 在自定义小部件顶部添加飞溅效果
问题描述
我有以下小部件:
class _BuildingItem extends StatelessWidget {
final String address;
final String zip;
final String zipCityName;
final Image image;
const _BuildingItem({Key? key,
required this.address,
required this.zip,
required this.zipCityName,
required this.image
}): super(key: key);
@override
Widget build(BuildContext context) {
return Container(
color: Colors.transparent,
child: Column(
children: [
ClipRect(
child: image,
),
Container(
color: Colors.lightBlue,
child: DefaultTextStyle(
style: TextStyle(
color: Colors.white,
fontFamily: "Roboto",
fontSize: 20,
),
child: Column(
children: [
Container(
padding: EdgeInsets.only(top: 5.0),
child: Text(
this.address
),
),
Container(
padding: EdgeInsets.symmetric(vertical: 5.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
this.zip + ", "
),
Text(
this.zipCityName
),
],
)
),
],
),
),
),
],
)
);
}
}
我希望在此小部件之上添加飞溅效果。将小部件包装在 InkWell 中并不像我想要的那样工作,因为它会将飞溅效果放在父小部件上。我可能对此视而不见,但我应该如何在这个小部件内“合并”一个 InkWell 以在其上呈现飞溅效果?
解决方案
通过将小部件放入堆栈中并添加一个 Material 和 InkWell 小部件作为该堆栈的第二个子级来解决(以便将 InkWell 和 Material 小部件放在原始自定义小部件的顶部)。
推荐阅读
- ios - 将 AppStore 中的 Objc 项目迁移到 Swift 项目是否可行?
- ios - NSManagedObjectContext.performAndWait{} 导致崩溃
- node.js - 当架构包含“_”字符时,Adonisjs 模型名称
- swiftui - 当另一个视图处于活动状态时如何模糊背景?
- php - bigcommerce 休息 api v3 php
- java - 有谁知道如何在 Java 的特定位内生成一个数字?
- java - Instagram API 从应用程序关注用户不起作用
- android - 位置开关后存在android应用程序
- bash - Bash 循环遍历文件过早结束
- node.js - 从 Nodejs (Docker) 调用 RabbitMQ