Skip to content

CenterPlay Button causing error #578

@pavanjoshi914

Description

@pavanjoshi914

Widget causing error

 @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.transparent,
      child: Center(
        child: AnimatedOpacity(
          opacity: show ? 1.0 : 0.0,
          duration: const Duration(milliseconds: 300),
          child: Container(
            decoration: BoxDecoration(
              color: backgroundColor,
              shape: BoxShape.circle,
            ),
            child: Padding(
              padding: const EdgeInsets.all(12.0),
              // Always set the iconSize on the IconButton, not on the Icon itself:
              // https://github.com/flutter/flutter/issues/52980
              child: IconButton(
                iconSize: 32,
                icon: isFinished
                    ? Icon(Icons.replay, color: iconColor)
                    : AnimatedPlayPause(
                        color: iconColor,
                        playing: isPlaying,
                      ),
                onPressed: onPressed,
              ),
            ),
          ),
        ),
      ),
    );
  }
}

Error Caused

   The following assertion was thrown building IconButton(Icon, padding: EdgeInsets.all(8.0), dirty):
                    No Material widget found.
                    IconButton widgets require a Material widget ancestor.
                    In material design, most widgets are conceptually "printed" on a sheet of material. In Flutter's
                    material library, that material is represented by the Material widget. It is the Material widget
                    that renders ink splashes, for instance. Because of this, many material library widgets require that
                    there be a Material widget in the tree above them.
                    To introduce a Material widget, you can either directly include one, or use a widget that contains
                    Material itself, such as a Card, Dialog, Drawer, or Scaffold.
                    The specific widget that could not find a Material ancestor was:
                      IconButton
                    The ancestors of this widget were:
                      ...
                      Padding
                      DecoratedBox
                      Container
                      FadeTransition
                      AnimatedOpacity
                      ...
                    
                    The relevant error-causing widget was:
                      IconButton
                      IconButton:file:///C:/Users/91797/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/chewie-1.2.2/lib/src/center_play_button.dart:38:22
                    

chewie is working fine in my app just this exception is thrown

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions