-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Incorrect use of ParentDataWidget. #485
Description
Getting this error while using Chewie.
I/flutter ( 7546): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter ( 7546): The following assertion was thrown while applying parent data.:
I/flutter ( 7546): Incorrect use of ParentDataWidget.
I/flutter ( 7546): The ParentDataWidget Expanded(flex: 1) wants to apply ParentData of type FlexParentData to a
I/flutter ( 7546): RenderObject, which has been set up to accept ParentData of incompatible type StackParentData.
I/flutter ( 7546): Usually, this means that the Expanded widget has the wrong ancestor RenderObjectWidget. Typically,
I/flutter ( 7546): Expanded widgets are placed directly inside Flex widgets.
I/flutter ( 7546): The offending Expanded is currently placed inside a Stack widget.
I/flutter ( 7546): The ownership chain for the RenderObject that received the incompatible parent data was:
I/flutter ( 7546): Center ← Expanded ← Stack ← AbsorbPointer ← Listener ← _GestureSemantics ← RawGestureDetector ←
I/flutter ( 7546): GestureDetector ← _RawMouseRegion ← MouseRegion ← ⋯
CODE :
class VideoPlayerWidget extends StatefulWidget {
const VideoPlayerWidget({this.url});
final String url;
@OverRide
_VideoPlayerWidgetState createState() => _VideoPlayerWidgetState();
}
class _VideoPlayerWidgetState extends State {
ChewieController _chewieController;
VideoPlayerController _controller;
@OverRide
void initState() {
final Uri uri =
signMyObject(objectKey: widget.url, bucketName: BUCKET_NAME);
_controller = VideoPlayerController.network(uri.toString());
_chewieController = ChewieController(
videoPlayerController: _controller,
aspectRatio: ASPECT_RATIO,
autoInitialize: true,
autoPlay: true,
deviceOrientationsAfterFullScreen: [DeviceOrientation.portraitUp],
materialProgressColors: ChewieProgressColors(
playedColor: Colors.purple,
handleColor: Colors.purple,
backgroundColor: Colors.grey,
bufferedColor: Colors.purple[100],
),
placeholder: Container(
color: Colors.grey,
),
);
super.initState();
}
@OverRide
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
body: SafeArea(
child: Center(
child: Chewie(
controller: _chewieController,
),
),
),
),
);
}
@OverRide
void dispose() {
_controller.dispose();
_chewieController.dispose();
super.dispose();
}
}