Error:
2025-01-30T06:34:59Z [android] Error: e: file:///home/user/.pub-cache/hosted/pub.dev/flutter_web_auth_2-3.1.2/android/src/main/kotlin/com/linusu/flutter_web_auth_2/FlutterWebAuth2Plugin.kt:15:48 Unresolved reference: Registrar
2025-01-30T06:34:59Z [android]
2025-01-30T06:34:59Z [android] Error: e: file:///home/user/.pub-cache/hosted/pub.dev/flutter_web_auth_2-3.1.2/android/src/main/kotlin/com/linusu/flutter_web_auth_2/FlutterWebAuth2Plugin.kt:22:33 Unresolved reference: Registrar
Cause:
The error occurs because the code is referencing Registrar, a class from the old Flutter embedding API, which is no longer supported in Flutter 2.0 and beyond. Specifically, the error is in the file:
file:///home/user/.pub-cache/hosted/pub.dev/flutter_web_auth_2-3.1.2/android/src/main/kotlin/com/linusu/flutter_web_auth_2/FlutterWebAuth2Plugin.kt
The references to Registrar are found on lines 15 and 22 of the FlutterWebAuth2Plugin.kt file. These lines are attempting to use the deprecated Registrar class, which leads to the unresolved reference error in the context of newer versions of Flutter.
Origin:
The issue originates from using flutter_web_auth_2 version 3.1.2, which was not updated to support Flutter 2.0 and higher. This plugin still relies on the legacy Android embedding method (older than Flutter 1.12), which was removed starting from Flutter 1.12. The file in question, FlutterWebAuth2Plugin.kt, was written for the old embedding system, and when compiling with a newer version of Flutter (3.x in my case), it throws the unresolved reference error for Registrar.
Dependencies:
- Flutter version: Likely 3.28.0 (Beta), which uses the new embedding system.
- Plugin:
flutter_web_auth_2 version 3.1.2.