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] <title>package:flutter/src/widgets/navigator.dart': Failed assertion: line 5277 pos 12: '!_debugLocked': is not true. #985

Open
1 task done
surajgju opened this issue Sep 5, 2024 · 2 comments
Assignees

Comments

@surajgju
Copy link

surajgju commented Sep 5, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Package

youtube_player_flutter

What happened?

i switch version from 8.1.2 to 9.0.3 and i am unable to navigate back to previous screen from screen where video is playing.

here log : he following assertion was thrown while handling a gesture:
'package:flutter/src/widgets/navigator.dart': Failed assertion: line 5277 pos 12: '!_debugLocked': is not true.

Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
https://github.com/flutter/flutter/issues/new?template=2_bug.yml

When the exception was thrown, this was the stack:
#2 NavigatorState.pop (package:flutter/src/widgets/navigator.dart:5277:12)
#3 Navigator.pop (package:flutter/src/widgets/navigator.dart:2573:27)
#4 _YoutubePlayerBuilderState.build. (package:youtube_player_flutter/src/widgets/youtube_player_builder.dart:77:23)

What is the expected behaviour?

i should easily navigate back using icon button in leading app bar by Navigator.of(context).pop() .

How to reproduce?

1.when tap on navigate back leading in appbar which is inside widget YoutubePlayerBuilder it throw the error Failed assertion: line 5277 pos 12: '!_debugLocked': is not true.
2. i think this is youtube_player_flutter issue since its showing in Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
https://github.com/flutter/flutter/issues/new?template=2_bug.yml
3. i am writing back like this simple leading: IconButton(
icon: const Icon(Icons.arrow_back_ios), // Customize the icon as needed
onPressed: () => Navigator.of(context).pop(),
),

code snippet: Widget build(BuildContext context) {
ScreenUtil.init(context);
// final _chapterDetailProvider = Provider.of(context);
return Consumer(
builder: (context, _chapterDetailProvider, child) {
return chaptersTopicsList.isNotEmpty
? YoutubePlayerBuilder(
// key: UniqueKey(),
player: YoutubePlayer(
controller: videoController!,
onReady: () {
// isPlayerReady = true;
},
//aspectRatio:videoController!.value.isFullScreen ? 3/3 : 16 / 9 ,
aspectRatio: 16 / 8,

            bottomActions: [
              Expanded(
                  child: ClipRRect(
                borderRadius: BorderRadius.circular(10.0),
                child: BackdropFilter(
                  filter: ui.ImageFilter.blur(
                    sigmaX: 10.0,
                    sigmaY: 10.0,
                    //tileMode: TileMode.mirror
                  ),
                  child: Container(
                    margin: EdgeInsets.only(bottom: 5, left: 10, right: 10),
                    child: Row(
                      children: [
                        CurrentPosition(),
                        const SizedBox(width: 10.0),
                        ProgressBar(
                          isExpanded: true,
                          controller: videoController,
                          colors: ProgressBarColors(
                            playedColor: Colors.white,
                            handleColor: Colors.white,
                            bufferedColor: const Color.fromARGB(
                              60,
                              255,
                              255,
                              255,
                            ),
                            backgroundColor: Colors.white24,
                          ),
                        ),
                        const SizedBox(width: 10.0),
                        RemainingDuration(),
                        SizedBox(
                          width: 10.0,
                        ),
                        Row(
                          children: [
                            InkWell(
                                onTap: () {
                                  setState(() {
                                    videoController!.seekTo(Duration(
                                        seconds: videoController!
                                                .value.position.inSeconds -
                                            Duration(seconds: 10)
                                                .inSeconds));
                                  });
                                },
                                child: Container(
                                    child: Image.asset(
                                  "assets/img/rewind.png",
                                  filterQuality: FilterQuality.high,
                                  fit: BoxFit.fill,
                                  width: videoController!.value.isFullScreen
                                      ? 15.w
                                      : 20.w,
                                  height:
                                      videoController!.value.isFullScreen
                                          ? 45.h
                                          : 20.h,
                                ))),
                            SizedBox(
                              width: 5,
                            ),
                            InkWell(
                                onTap: () {
                                  setState(() {
                                    videoController!.seekTo(Duration(
                                        seconds: videoController!
                                                .value.position.inSeconds +
                                            10));
                                  });
                                },
                                child: Container(
                                    child: Image.asset(
                                  "assets/img/forward.png",
                                  filterQuality: FilterQuality.high,
                                  fit: BoxFit.fill,
                                  width: videoController!.value.isFullScreen
                                      ? 15.w
                                      : 20.w,
                                  height:
                                      videoController!.value.isFullScreen
                                          ? 45.h
                                          : 20.h,
                                ))),
                          ],
                        ),
                        Container(
                            margin: EdgeInsets.only(left: 7),
                            child: PlaybackSpeedButton()),
                        FullScreenButton(
                          controller: videoController!,
                        ),
                      ],
                    ),
                  ),
                ),
              ))
            ],
          ),
          builder: (context, player) {
            return Scaffold(
                backgroundColor: Colors.white,
                appBar: AppBar(
                    backgroundColor: Colors.white,
                    //subjectCircleFillCOlor,
                    elevation: 0,
                    centerTitle: true,
                    flexibleSpace: Image(
                      image: AssetImage(Images.homebgImg),
                      fit: BoxFit.cover,
                      // height: 25,
                    ),
                    title: GestureDetector(
                      onTap: () {
                        // Navigator.of(context).push(MaterialPageRoute(builder: (builder)=>YoutubePlayerDemoApp()));
                      },
                      child: SvgPicture.asset(
                        "assets/img/logo.svg",
                        semanticsLabel: 'Vidya mine',
                        width: 125.w,
                        height: 25.h,
                      ),
                    ),
                    leading: IconButton(
                      icon: const Icon(Icons.arrow_back_ios), // Customize the icon as needed
                      onPressed: () => Navigator.of(context).pop(), // error line
                    ),

Flutter Doctor Output

[[✓] Flutter (Channel stable, 3.19.6, on macOS 14.4.1 23E224 darwin-arm64, locale en-IN)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[!] Xcode - develop for iOS and macOS (Xcode 15.2)
    ✗ Unable to get list of installed Simulator runtimes.
    ✗ CocoaPods not installed.
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart
        side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To install see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.1)
[✓] VS Code (version 1.92.0)
[✓] Connected device (3 available)
[✓] Network resources
@hayoungko
Copy link

I'm having the same problem.

@mashmir
Copy link

mashmir commented Oct 13, 2024

PopScope(
canPop: false,
onPopInvoked: (didPop) { // <== Replace this function with onPopInvokedWithResult: (didPop, result) as this has been deprecated
final controller = widget.player.controller;
if (controller.value.isFullScreen) {
widget.player.controller.toggleFullScreenMode();
} else {
Navigator.pop(context);
}
},
child: widget.player,
),
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants