Flutter App dies with "Failed assertion: line 4901 pos 16: 'child is! ParentDataElement<ParentData>': is not true."
Checking the logs you've provided, the error seems to point on MediaControlWidget.dart
.
════════ (5) Exception caught by widgets library ═══════════════════════════════════════════════════'package:flutter/src/widgets/framework.dart': Failed assertion: line 4901 pos 16: 'child is! ParentDataElement<ParentData>': is not true.The relevant error-causing widget was: Expanded file:///C:/Users/narmo/Documents/theBigApp/TheBigApp/remote_appv1/lib/MediaControlWidget.dart:28:9════════════════════════════════════════════════════════════════════════════════════════════════════════════ (6) Exception caught by widgets library ═══════════════════════════════════════════════════'package:flutter/src/widgets/framework.dart': Failed assertion: line 4901 pos 16: 'child is! ParentDataElement<ParentData>': is not true.The relevant error-causing widget was: Expanded file:///C:/Users/narmo/Documents/theBigApp/TheBigApp/remote_appv1/lib/MediaControlWidget.dart:70:9════════════════════════════════════════════════════════════════════════════════════════════════════
I've tried running error-causing the snippet, and the ones causing the issue is how Spacer
is used.
From your code, Spacer
is used inside an Expanded
widget, similar to this code.
Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Expanded(flex: 1, child: Spacer()), Expanded(flex: 1, child: Container(color: Colors.greenAccent)), Expanded(flex: 1, child: Spacer()), ],),
Since Spacer
is an "Expanded widget", it should be used alongside Expanded
widgets. It should be used similarly to this code.
Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Spacer(flex: 1), Expanded(flex: 1, child: Container(color: Colors.greenAccent)), Spacer(flex: 1), ],),