In GestureDetector
in onTap event i have a if condition like this:
Positioned(
left: 1.0,
top: -20.0,
child: GestureDetector(
onTap: () => {
if (widget.status == RemoteStatus.edit)
{
showChooseProfileScreen(0).then((val) {
if (val != null && val) {
print("------> $val");
}
})
}
else {
if (!onTapRaised)
{
sendCommand(54); //Expected to find '}'. error
onTapRaised = true;
releaseTapRaised(onTapRaised);
}
}
},
child: Container(
margin: EdgeInsets.only(left: 20.0, top: 20.0),
Someone knows why i got error Expected to find '}'.
in sendCommand(54); part?
I run flutter clean before but i still got this error.
Change
onTap: () => {
to
onTap: () {
Because otherwise Dart interprets it as if you were returning map literal, not executing set of instructions.
Example:
Map foo() => {'key': 'value'}; // returns Map
void bar() { print('just executes set of instructions'); } // returns void
Refer to Functions section in the Language tour.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With