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

[BUG] _TypeError was thrown building YoutubePlayerBuilder #271

Closed
lalbuquerque opened this issue Jun 25, 2020 · 6 comments
Closed

[BUG] _TypeError was thrown building YoutubePlayerBuilder #271

lalbuquerque opened this issue Jun 25, 2020 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@lalbuquerque
Copy link

Describe the bug

I'm trying to use the full screen video feature like that:

      YoutubePlayerBuilder(
        player: YoutubePlayer(
          controller: _getController(slides[0].uri),
          showVideoProgressIndicator: true,
          progressIndicatorColor: Colors.amber,
          progressColors: ProgressBarColors(
            playedColor: Colors.amber,
            handleColor: Colors.amberAccent,
          ),
        ),
        builder: (context, player) {
          return Scaffold(
            appBar: CustomAppBar(title: "my title"),
            body: RefreshIndicator(
              onRefresh: () {
                bloc.add(
                  Refresh(),
                );
                return _refreshCompleter.future;
              },
              child: _buildWidgetList(slides, player),
            ),
          );
        },
      )

And I'm receiving this error:

The following _TypeError was thrown building YoutubePlayerBuilder(dirty, state: _YoutubePlayerBuilderState#445a8)
type 'Container' is not a subtype of type 'YoutubePlayer'

with the trace _YoutubePlayerBuilderState.build(package:youtube_player_flutter/src/widgets/youtube_player_builder.dart:81:33)

Which leads to the following part of YoutubePlayerBuilder:

    final _player = Container(
      key: playerKey,
      child: WillPopScope(
        onWillPop: () async {
          final controller = widget.player.controller;
          if (controller.value.isFullScreen) {
            widget.player.controller.toggleFullScreenMode();
            return false;
          }
          return true;
        },
        child: widget.player,
      ),
    );
    final child = widget.builder(context, _player);

To Reproduce
Wrap your Scaffold with YoutubePlayerBuilder

Expected behavior
Show up the layout without crashing

Technical Details:

  • Device: Pixel 2
  • OS: API 29
  • Version: the error occurs in both ^7.0.0+3 and ^7.0.0+6 versions
@lalbuquerque lalbuquerque added the bug Something isn't working label Jun 25, 2020
@sarbagyastha
Copy link
Owner

Whats the type for second argument in your _buildWidgetList ?

@lalbuquerque
Copy link
Author

Whats the type for second argument in your _buildWidgetList ?

@sarbagyastha it's YoutubePlayer

@sarbagyastha
Copy link
Owner

It should be Widget.

@lalbuquerque
Copy link
Author

lalbuquerque commented Jun 25, 2020

@sarbagyastha so the builder doesn't deliver a YoutubePlayer at all or I just have to do an explicit cast on player?

@sarbagyastha
Copy link
Owner

@lalbuquerque
Copy link
Author

Ok @sarbagyastha I get it.

I just think the builder parameter player having the same name as the argument that receives a YoutubePlayer instance may be a little bit confusing. Maybe if its name was playerWidget it would be a little better.

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

2 participants