Code:
final tapRecognizer = TapGestureRecognizer()
..onTap!() = () =>
AppGlobalFunctions().openExternalLink("https://xxxxxx.xxx");
Error log:
Launching lib/main.dart on Redmi Note 7 Pro in debug mode...
Running Gradle task 'assembleDebug'...
lib/modules/auth/phone_auth/phone_auth.dart:15:16: Error: Can't assign to this.
..onTap!() = () =>
^
Target kernel_snapshot failed: Exception
FAILURE: Build failed with an exception.
* Where:
Script '/Users/udit/Downloads/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 1201
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command '/Users/udit/Downloads/flutter/bin/flutter'' finished with non-zero exit value 1
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 6s
Exception: Gradle task assembleDebug failed with exit code 1
How to duplicate:
Create new flutter project
Copy final tapRecognizer = TapGestureRecognizer() ..onTap!() = () => debugPrint("Hello world");
and paste code in _MyHomePageState
import 'package:flutter/gestures.dart' import 'package:flutter/gestures.dart';
run project
i think you want to assigning the OpenExternaLink function to the tapRecognizer
so do it like this:
final tapRecognizer = TapGestureRecognizer()
..onTap = () =>
AppGlobalFunctions().openExternalLink("https://xxxxxx.xxx");