I want to implement gestures detector in appBar. When user click image or name and it direct to another page. But it display error Found this candidate, but the arguments don't match. GestureDetector({ ^^^^^^^^^^^^^^^ Try again after fixing the above error(s).
I was trying many things but I get only errors. I am new in all of that and I would appreciate some help.
This my appBar code
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
flexibleSpace: GestureDetector(
onTap: (){
Navigator.pushNamed(context, LoginPage.routeName);
},
title: Row(
children: [
const CircleAvatar(
radius: 20,
backgroundImage: NetworkImage(
'https://i1.sndcdn.com/artworks-79AS3zNyDuB420uC-pKTA2w-t500x500.jpg'),
),
const SizedBox(
width: 10,
),
Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
'Welcome Back!',
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.w400,
color: Colors.black87)
),
Text('Guest',
style: TextStyle(
fontSize: 19,
fontWeight: FontWeight.w600,
color: Colors.black87
)),
],
),
],
)),
forceMaterialTransparency: true,
),
body: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/header_home.jpg'),
fit: BoxFit.cover,
),
),
child: SingleChildScrollView(
padding: EdgeInsets.symmetric(vertical: 16),
child: Column(
children: [
filterField(),
],
),
),
),
),
);
2
Answers
GestureDetector
requires a child Widget to execute, the Gesture behaviour will execute on the child widget.Whatever widget you want clickable, just wrap with the
GestureDetector
and add onTap and other required property.Basic example:
this is what you need to do. referring to ankushlokhande answer
keep in mind to change these parts to adapt to your code needs
Navigator.pushNamed(context, LoginPage.routeName);