'Agora Black screen in Flutter didn't open the camera?

I'm trying to make an video calling app using Agora But Camera didn't open it shows a black screen I tried several ways but it doesn't work. My appid and temptoken are updated(I make it under the 24 hours) Add the Androidmainfist.xml are added in the plug in docs Still I get the blackscreen

import 'dart:convert';
import 'package:agora_uikit/agora_uikit.dart';
import 'package:flutter/material.dart';
// import 'package:get/get.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:http/http.dart';

class VideoCalll extends StatefulWidget {
  VideoCalll({Key? key}) : super(key: key);

  @override
  State<VideoCalll> createState() => _VideoCalllState();
}

class _VideoCalllState extends State<VideoCalll> {
  late final AgoraClient _client;
  late bool _loading = true;
  String tempToken = "";

  @override
  void initState() {
    getToken();
    super.initState();
  }

  Future<void> getToken() async {
    String link =
        "https://agora-node-tokenserver.kumaresanjackie.repl.co/access_token?channelName=demoproject";

    Response _response = await get(Uri.parse(link));
    Map data = jsonDecode(_response.body);
    setState(() {
      tempToken = data["token"];
    });
    // late final AgoraClient
    _client = AgoraClient(
        agoraConnectionData: AgoraConnectionData(
          appId: "4b463a1f8d3448928f4450c9be2db3ba",
          channelName: 'demoproject',
          tempToken: data["token"],
        ),
        enabledPermission: [Permission.camera, Permission.microphone]);

    Future.delayed(const Duration(seconds: 2))
        .then((value) => setState(() => _loading = false));
  }

  @override
  Widget build(BuildContext context) {
    return _loading
        ? const Center(child: CircularProgressIndicator())
        : Scaffold(
            body: SafeArea(
              child: Stack(
                children: [
                  AgoraVideoViewer(
                    client: _client,
                  ),
                  AgoraVideoButtons(client: _client),
                ],
              ),
            ),
          );
  }
}


Solution 1:[1]

Black screens usually appear when you are using the APP_ID of the project that is already created using agora.

Follow these steps to get rid of it:

  1. Open the projects section where you can see your projects
  2. Click on the CREATE button to create a new project

Note: When you will click the create button you will as below:

Testing mode and secured mode

You can see there are two options: 1 is secured and the other is testing

  1. Click on the testing Mode: APP ID after creating this project you can now use only your APP_ID for the testing, now you do not need token to run the video stream or video call.

Hope this helps to solve your issue!

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 Ethan