0

When I run my app I found black screen after giving all permission. Please resolve my problem. Camera is not working properly the all screen became black only buttons is showing on the screen.

import 'package:flutter/material.dart';
import 'package:helo/app_id.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}
class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);
  final String title;
  @override
  State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
  AgoraClient client = AgoraClient(agoraConnectionData : AgoraConnectionData(appId: appId, channelName: 'test') , enabledPermission: [Permission.camera, Permission.microphone]) ;
  @override
  void initState(){
    super.initState();
    client.initialize();
  }

  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Stack(
        children: [
          AgoraVideoViewer(client: client),
          AgoraVideoButtons(client: client)
        ],
      )
    );
  }
}
amit.flutter
  • 883
  • 9
  • 27

2 Answers2

0

Android Open the AndroidManifest.xml file and add the required device permissions to the file.

<manifest>
...
<uses-permission  android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission  android:name="android.permission.INTERNET"  />
<uses-permission  android:name="android.permission.RECORD_AUDIO"  />
<uses-permission  android:name="android.permission.CAMERA"  />
<uses-permission  android:name="android.permission.MODIFY_AUDIO_SETTINGS"  />
<uses-permission  android:name="android.permission.ACCESS_NETWORK_STATE"  />
<!-- The Agora SDK requires Bluetooth permissions in case users are using Bluetooth devices.-->
<uses-permission  android:name="android.permission.BLUETOOTH"  />
...
</manifest>

iOS Open info.plist and add:

Privacy - Microphone Usage Description, and add a note in the Value column.
Privacy - Camera Usage Description, and add a note in the Value column.


<key>NSPhotoLibraryUsageDescription</key>
<string>App needs access to photo lib for profile images</string>

also see this post

<key>NSCameraUsageDescription</key>
<string>To capture profile photo please grant camera access</string>
amit.flutter
  • 883
  • 9
  • 27
0

I don't see agora_uikit in your import statement. Please make sure that you have imported the UIKit in your dart file. Other than that black screen can be because of a multiple reasons, without the logs it is very hard to tell the exact cause. Have a look at this doc that shares all the possible causes: https://docs.agora.io/en/video/faq/video_blank

  • Hey. I have another issue with agora, I just started working with it. I posted the question here https://stackoverflow.com/questions/74280910/trouble-using-agora-rtc-engine-in-my-flutter-app – LearnFlutter Nov 02 '22 at 14:48