为什么 onTap of inkwell 不工作?我在每个地方都试过了,但它不起作用
why onTap of inkwell is not working ? I tried at every place but its is not working
我是 Flutter 新手。为什么 onTap of inkwell 不工作?我在每个地方都尝试过,但它不起作用。我做错了什么?有其他可能的选择吗?
InkWell(
onTap: ()=>Search_box(),
child: Padding(
padding: const EdgeInsets.only(top: 5),
child: InkWell(
onTap: ()=>Search_box(),
child: Container(
height: 40,
// search wala container
padding: const EdgeInsets.symmetric(horizontal: 8),
margin: const EdgeInsets.symmetric(horizontal: 3, vertical: 0),
decoration: BoxDecoration(
shape: BoxShape.rectangle,
color: Colors.grey[400], borderRadius: BorderRadius.circular(24)),
child: InkWell(
onTap: (() {
Search_box();
}),
child: Row(
children: [
GestureDetector(
onTap: () {
Search_box();
},
child: Container(
child: const Icon(
Icons.search,
color: Colors.blueAccent,
),
margin: const EdgeInsets.fromLTRB(3, 0, 7, 0),
),
),
Expanded(
child: GestureDetector(
onTap: (){
Search_box();
},
child: InkWell(
onTap: ()=>Search_box(),
child: Container(
child: Text("Lets search someone"),
),
),
),
),
GestureDetector(
onTap: () {
Search_box();
},
child: Container(
child: Icon(
Icons.person,
color: Colors.grey[600],
),
margin: EdgeInsets.fromLTRB(3, 0, 7, 0),
),
The InkWell widget must have a Material widget as an ancestor. The Material widget is where the ink reactions are actually painted
所以你应该将墨水瓶包裹在 Material 小部件中
在你的情况下试试这个
Padding(
padding: const EdgeInsets.only(top: 5),
child: Container(
height: 40,
padding: const EdgeInsets.symmetric(
horizontal: 8),
margin: const EdgeInsets.symmetric(
horizontal: 3, vertical: 0),
decoration: BoxDecoration(
shape: BoxShape.rectangle,
color: Colors.grey[400],
borderRadius:
BorderRadius.circular(24)),
child: Material(
clipBehavior: Clip.antiAlias,
shape: RoundedRectangleBorder(borderRadius:BorderRadius.circular(22.0)),
color: Colors.grey[400],
child: InkWell(
onTap: (() {
// yor method here
}),
child: Row(children: [
Container(
child: const Icon(
Icons.search,
color: Colors.blueAccent,
),
margin:
const EdgeInsets.fromLTRB(
3, 0, 7, 0),
),
Expanded(
child: Container(
child: Text(
"Lets search someone"),
),
),
Container(
child: Icon(
Icons.person,
color: Colors.grey[600],
),
margin: EdgeInsets.fromLTRB(
3, 0, 7, 0),
)
]),
),
),
))
这应该有效:
Material(
color: Colors.white,
child: InkWell(
onTap: ()=>Search_box(),
child: Padding(
padding: const EdgeInsets.only(top: 5),
child: InkWell(
onTap: ()=>Search_box(),
child: Container(
height: 40,
// search wala container
padding: const EdgeInsets.symmetric(horizontal: 8),
margin: const EdgeInsets.symmetric(horizontal: 3, vertical: 0),
decoration: BoxDecoration(
shape: BoxShape.rectangle,
color: Colors.grey[400], borderRadius: BorderRadius.circular(24)),
child: InkWell(
onTap: (() {
Search_box();
}),
child: Row(
children: [
GestureDetector(
onTap: () {
Search_box();
},
child: Container(
child: const Icon(
Icons.search,
color: Colors.blueAccent,
),
margin: const EdgeInsets.fromLTRB(3, 0, 7, 0),
),
),
Expanded(
child: GestureDetector(
onTap: (){
Search_box();
},
child: InkWell(
onTap: ()=>Search_box(),
child: Container(
child: Text("Lets search someone"),
),
),
),
),
GestureDetector(
onTap: () {
Search_box();
},
child: Container(
child: Icon(
Icons.person,
color: Colors.grey[600],
),
margin: EdgeInsets.fromLTRB(3, 0, 7, 0),
),
)
)
)
)
)
)
)
)
我是 Flutter 新手。为什么 onTap of inkwell 不工作?我在每个地方都尝试过,但它不起作用。我做错了什么?有其他可能的选择吗?
InkWell(
onTap: ()=>Search_box(),
child: Padding(
padding: const EdgeInsets.only(top: 5),
child: InkWell(
onTap: ()=>Search_box(),
child: Container(
height: 40,
// search wala container
padding: const EdgeInsets.symmetric(horizontal: 8),
margin: const EdgeInsets.symmetric(horizontal: 3, vertical: 0),
decoration: BoxDecoration(
shape: BoxShape.rectangle,
color: Colors.grey[400], borderRadius: BorderRadius.circular(24)),
child: InkWell(
onTap: (() {
Search_box();
}),
child: Row(
children: [
GestureDetector(
onTap: () {
Search_box();
},
child: Container(
child: const Icon(
Icons.search,
color: Colors.blueAccent,
),
margin: const EdgeInsets.fromLTRB(3, 0, 7, 0),
),
),
Expanded(
child: GestureDetector(
onTap: (){
Search_box();
},
child: InkWell(
onTap: ()=>Search_box(),
child: Container(
child: Text("Lets search someone"),
),
),
),
),
GestureDetector(
onTap: () {
Search_box();
},
child: Container(
child: Icon(
Icons.person,
color: Colors.grey[600],
),
margin: EdgeInsets.fromLTRB(3, 0, 7, 0),
),
The InkWell widget must have a Material widget as an ancestor. The Material widget is where the ink reactions are actually painted
所以你应该将墨水瓶包裹在 Material 小部件中
在你的情况下试试这个
Padding(
padding: const EdgeInsets.only(top: 5),
child: Container(
height: 40,
padding: const EdgeInsets.symmetric(
horizontal: 8),
margin: const EdgeInsets.symmetric(
horizontal: 3, vertical: 0),
decoration: BoxDecoration(
shape: BoxShape.rectangle,
color: Colors.grey[400],
borderRadius:
BorderRadius.circular(24)),
child: Material(
clipBehavior: Clip.antiAlias,
shape: RoundedRectangleBorder(borderRadius:BorderRadius.circular(22.0)),
color: Colors.grey[400],
child: InkWell(
onTap: (() {
// yor method here
}),
child: Row(children: [
Container(
child: const Icon(
Icons.search,
color: Colors.blueAccent,
),
margin:
const EdgeInsets.fromLTRB(
3, 0, 7, 0),
),
Expanded(
child: Container(
child: Text(
"Lets search someone"),
),
),
Container(
child: Icon(
Icons.person,
color: Colors.grey[600],
),
margin: EdgeInsets.fromLTRB(
3, 0, 7, 0),
)
]),
),
),
))
这应该有效:
Material(
color: Colors.white,
child: InkWell(
onTap: ()=>Search_box(),
child: Padding(
padding: const EdgeInsets.only(top: 5),
child: InkWell(
onTap: ()=>Search_box(),
child: Container(
height: 40,
// search wala container
padding: const EdgeInsets.symmetric(horizontal: 8),
margin: const EdgeInsets.symmetric(horizontal: 3, vertical: 0),
decoration: BoxDecoration(
shape: BoxShape.rectangle,
color: Colors.grey[400], borderRadius: BorderRadius.circular(24)),
child: InkWell(
onTap: (() {
Search_box();
}),
child: Row(
children: [
GestureDetector(
onTap: () {
Search_box();
},
child: Container(
child: const Icon(
Icons.search,
color: Colors.blueAccent,
),
margin: const EdgeInsets.fromLTRB(3, 0, 7, 0),
),
),
Expanded(
child: GestureDetector(
onTap: (){
Search_box();
},
child: InkWell(
onTap: ()=>Search_box(),
child: Container(
child: Text("Lets search someone"),
),
),
),
),
GestureDetector(
onTap: () {
Search_box();
},
child: Container(
child: Icon(
Icons.person,
color: Colors.grey[600],
),
margin: EdgeInsets.fromLTRB(3, 0, 7, 0),
),
)
)
)
)
)
)
)
)