When trying to run a url on browser with url_launcher plugin, I am getting this error on the release build on android. IOS and the android debug variant works fine.
E/flutter: [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: MissingPluginException(No implementation found for method canLaunch on channel plugins.flutter.io/url_launcher)
#0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:157)
<asynchronous suspension>
#1 canLaunch (package:url_launcher/url_launcher.dart:124)
<asynchronous suspension>
#2 _HomeWidgetState.launchURL (package:pool_inspection/src/pages/home/home.dart:323)
<asynchronous suspension>
Here's my code
DialogButton(
color: Color(0xFF0B9CDA),
child: Text(
"Login Now",
style: TextStyle(
color: Colors.white, fontSize: 18),
),
onPressed: () {
setState(() {
launchURL();
});
},
)
Method for url launch
Future<void> launchURL() async {
const url = 'https://sometesturl.com';
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}
url_launcher version
url_launcher: ^5.7.10
Whats the issue I am unable to trace. I have already tried flutter clean,flutter pub get, Invalidate Cache/Restart as suggested by other answers.