Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled Exception: MissingPluginException(No implementation found for method evaluateJavascript on channel com.pichillilorenzo/flutter_inappwebview_0) #463

Closed
himanshu64 opened this issue Mar 17, 2021 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@himanshu64
Copy link

`E/flutter (11010): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: MissingPluginException(No implementation found for method evaluateJavascript on channel com.pichillilorenzo/flutter_inappwebview_0)
E/flutter (11010): #0 MethodChannel._invokeMethod
package:flutter/…/services/platform_channel.dart:157
E/flutter (11010):

E/flutter (11010): #1 MethodChannel.invokeMethod
package:flutter/…/services/platform_channel.dart:332
E/flutter (11010): #2 InAppWebViewController.evaluateJavascript
package:flutter_inappwebview/src/in_app_webview_controller.dart:1350
E/flutter (11010): #3 _MobileYoutubePlayerState._callMethod
package:youtube_player_iframe/…/players/youtube_player_mobile.dart:288
E/flutter (11010):
E/flutter (11010): #4 YoutubePlayerController.pause
package:youtube_player_iframe/src/controller.dart:101
E/flutter (11010): #5 _YtWidgetState.deactivate
package:friskutensukker/widgets/youtubePlayer.dart:104
E/flutter (11010): #6 StatefulElement.deactivate
package:flutter/…/widgets/framework.dart:4847
E/flutter (11010): #7 _InactiveElements._deactivateRecursively
package:flutter/…/widgets/framework.dart:2016
E/flutter (11010): #8 SingleChildRenderObjectElement.visitChildren
package:flutter/…/widgets/framework.dart:6105
E/flutter (11010): #9 _InactiveElements._deactivateRecursively
package:flutter/…/widgets/framework.dart:2018
E/flutter (11010): #10 ComponentElement.visitChildren
package:flutter/…/widgets/framework.dart:4681
E/flutter (11010): #11 _InactiveElements._deactivateRecursively
package:flutter/…/widgets/framework.dart:2018
E/flutter (11010): #12 MultiChildRenderObjectElement.visitChildren
package:flutter/…/widgets/framework.dart:6218
E/flutter (11010): #13 _InactiveElements._deactivateRecursively
package:flutter/…/widgets/framework.dart:2018
E/flutter (11010): #14 MultiChildRenderObjectElement.visitChildren
package:flutter/…/widgets/framework.dart:6218
E/flutter (11010): #15 _InactiveElements._deactivateRecursively
package:flutter/…/widgets/framework.dart:2018
E/flutter (11010): #16 SingleChildRenderObjectElement.visitChildren
package:flutter/…/widgets/framework.dart:6105
E/flutter (11010): #17 _InactiveElements._deactivateRecursively
package:flutter/…/widgets/framework.dart:2018
E/flutter (11010): #18 SingleChildRenderObjectElement.visitChildren
package:flutter/…/widgets/framework.dart:6105
E/flutter (11010): #19 _InactiveElements._deactivateRecursively
package:flutter/…/widgets/framework.dart:2018
E/flutter (11010): #20 SingleChildRenderObjectElement.visitChildren
package:flutter/…/widgets/framework.dart:6105
E/flutter (11010): #21 _InactiveElements._deactivateRecursively
package:flutter/…/widgets/framework.dart:2018
E/flutter (11010): #22 SingleChildRenderObjectElement.visitChildren
package:flutter/…/widgets/framework.dart:6105
E/flutter (11010): #23 _InactiveElements._deactivateRecursively
package:flutter/…/widgets/framework.dart:2018
E/flutter (11010): #24 ComponentElement.visitChildren
package:flutter/…/widgets/framework.dart:4681
E/flutter (11010): #25 _InactiveElements._deactivateRecursively
package:flutter/…/widgets/framework.dart:2018
E/flutter (11010): #26 SingleChildRenderObjectElement.visitChildren
package:flutter/…/widgets/framework.dart:6105
E/flutter (11010): #27 _InactiveElements._deactivateRecursively
package:flutter/…/widgets/framework.dart:2018
E/flutter (11010): #28 ComponentElement.visitChildren
package:flutter/…/widgets/framework.dart:4681`

Technical Details:

  • Device: Emulator Nexus 5x API29
  • OS: Android
  • Version [e.g. 22]

Additional context
Full screen issue

@himanshu64 himanshu64 added the bug Something isn't working label Mar 17, 2021
@Babwenbiber
Copy link

I could kinda reproduce this error.
So my problem I was trying to solve is the following:
I want to use the YouTube player as a simple Widget and don't touch my existing code above or below the player, just because I want to use fullscreen.
However, the fullscreen should really be a fullscreen and thus be the only thing visible in the screen.
For this I created a button in the bottom actions, that opens a dialog with a full screen player.
But this somehow breaks the video. Finally when I close the fullscreen I get the error above.
I wrote a mini example in GitHub. Let me know if u could reproduce this and if there is an easier way to achieve the scenario above.

@MatteoAntolini
Copy link

This error is caused because when you push another screen/dialog and attach the controller, the channel id change.

To solve this issue you can create another controller inside the new screen.

Inside your main widget:

YoutubePlayer(
          progressIndicatorColor: AppColors.orange2,
          controller: controller,
          thumbnail: CachedNetworkImage(
            imageUrl: widget.image!,
            fit: BoxFit.fill,
          ),
          bottomActions: [
            const SizedBox(width: 5.0),
            CurrentPosition(),
            const SizedBox(width: 5.0),
            ProgressBar(isExpanded: true),
            RemainingDuration(),
            IconButton(
              icon: Icon(
                controller.value.isFullScreen
                    ? Icons.fullscreen_exit
                    : Icons.fullscreen,
                color: Colors.white,
              ),
              onPressed: () async {
                showDialog(
                    context: context,
                    builder: (context) => FullScreenVideo(
                          videoId: videoId!,
                          image: widget.image!,
                        ));
              },
            )
          ],
        ),

FullScreenVideo

class FullScreenVideo extends StatefulWidget {
  final String videoId;
  final String image;

  FullScreenVideo({required this.videoId, required this.image});

  @override
  State<FullScreenVideo> createState() => _FullScreenVideoState();
}

class _FullScreenVideoState extends State<FullScreenVideo> {
  late YoutubePlayerController controller;

  @override
  void initState() {
    super.initState();
    controller = YoutubePlayerController(
        initialVideoId: widget.videoId,
        flags: YoutubePlayerFlags(
            loop: true,
            controlsVisibleAtStart: true,
            mute: false,
            autoPlay: false))
      ..toggleFullScreenMode();
  }

  @override
  Widget build(BuildContext context) {
    return WillPopScope(
      onWillPop: () async {
        controller.toggleFullScreenMode();
        return true;
      },
      child: Scaffold(
        body: YoutubePlayerBuilder(
          player: YoutubePlayer(
              progressIndicatorColor: AppColors.orange2,
              controller: controller,
              bottomActions: [
                const SizedBox(width: 5.0),
                CurrentPosition(),
                const SizedBox(width: 5.0),
                ProgressBar(isExpanded: true),
                RemainingDuration(),
                IconButton(
                  icon: Icon(
                    controller.value.isFullScreen
                        ? Icons.fullscreen_exit
                        : Icons.fullscreen,
                    color: Colors.white,
                  ),
                  onPressed: () async {
                    controller.toggleFullScreenMode();
                    Navigator.of(context).pop();
                  },
                )
              ],
              thumbnail: CachedNetworkImage(
                imageUrl: widget.image,
                fit: BoxFit.fill,
              )),
          builder: (context, player) {
            return player;
          },
        ),
      ),
    );
  }

  @override
  void dispose() {
    controller.dispose();
    super.dispose();
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants