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),
],
),
Narmondur
Updated on December 21, 2022Comments
-
Narmondur over 1 year
I'll get right to it. My app crashes with the error specified in the title, and after significant digging around I have yet to find a solution.
What should this do and what is the problem?
Opening the application brings up the main menu (mainView.dart) and if you have the server.py running and have remembered to put in the correct IP addresses and ports so that your phone can talk to your computer inside the same LAN, you should be set to reproduce the bug. In youtube view, you should be able to paste a link to a youtube video of your choosing and have the server script prompt Selenium webdriver to play said video on a browser window. However, while the video plays correctly and such, sending the link causes the entire app to break, symptoms being crashes in the media control widget as well as the main view, should you return to it.
Connector class is written as a singleton and should provide up to date data to the GUI widgets based on JSON strings sent by the sendSystemState function in server.py. Updates are handled by the Providers.
I have no idea what causes the error messages, and neither do I have any idea on how to fix it. Any help would be greatly appreciated.
Reproducing the bug
- Run main.py with server.py in the same folder
- start up the application
- hit the youtube button
- Paste a youtube video URL to the text field and hit the trailing icon button
- let Selenium do its magic
- by this point you should see the media control widget at the bottom of the youtube view break
The code!
I couldn't paste all the code needed to reproduce the app and the issue here, so I made a gist-paste: all the code used
On request I can post individula files, but I couldn't for the life of me figure out how to limit the required code while still being able to reproduce what's happening accurately.
-
Andrewcpu over 2 yearsThis was exactly the cause in my case. Thank you.