''onRequestPermissionsResult' overrides nothing when requesting access to storage using flutter
I am trying to get permission to access music files in android using onAudioQuery package flutter but it is giving me this error:
e: C:\flutter\.pub-cache\hosted\pub.dartlang.org\on_audio_query-2.6.0\android\src\main\kotlin\com\lucasjosino\on_audio_query\OnAudioQueryPlugin.kt: (38, 1): Class 'OnAudioQueryPlugin' is not abstract and does not implement abstract member public abstract fun onRequestPermissionsResult(p0: Int, p1: Array<(out) String!>, p2: IntArray): Boolean defined in io.flutter.plugin.common.PluginRegistry.RequestPermissionsResultListener
e: C:\flutter\.pub-cache\hosted\pub.dartlang.org\on_audio_query-2.6.0\android\src\main\kotlin\com\lucasjosino\on_audio_query\OnAudioQueryPlugin.kt: (148, 5): 'onRequestPermissionsResult' overrides nothing
FAILURE: Build failed with an exception.
And My code is here:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
final OnAudioQuery _audioQuery = OnAudioQuery();
bool permissionStatus = false;
if (!kIsWeb) {
permissionStatus = await _audioQuery.permissionsStatus();
if (!permissionStatus) {
permissionStatus = await _audioQuery.permissionsRequest();
}
}
runApp(
ProviderScope(
child: MaterialApp(
debugShowCheckedModeBanner: false,
themeMode: ThemeMode.dark,
darkTheme: MyTheme.themeData,
home:
permissionStatus == true ? const SplashScreen() : const ErrorPage(),
),
),
);
}
Solution 1:[1]
You are probably using Flutter 3 and unfortunately on_audio_query 2.6 is not compatible with Flutter 3
Solution 2:[2]
I've updated the on_audio_query
plugin and now it supports Flutter 3
.
Update to:
dependencies:
on_audio_query: ^2.6.1
See on Pub.dev
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Sh4msi |
Solution 2 | Lucas Josino |