Error: Incorrect use of ParentDataWidget.

This Errors is posted by seven.srikanth at 12/7/2018 6:28:25 PM

Error:Incorrect use of ParentDataWidget. Expanded widgets must be placed inside Flex widgets. Expanded(no depth, flex: 1, dirty) has no flex ancestor at all. Explanation This error means that you can only place an Expandedfont-size: 1rem;]( Widget inside Flex Widget. For example, below code will throw this kind of error. font-size: 1rem;]( import 'package:flutter/material.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { Widget titlesection = Container( padding: EdgeInsets.all(10.0), child: Expanded( child: Row( children: [ Column( children: [ Container( padding: EdgeInsets.only(bottom: 8.0), child: Text( "Some Lage Somthing", style: TextStyle(fontWeight: FontWeight.bold), ), ), Text("Someplace, Country") ], ), Icon(Icons.star) ], ), ), ); return MaterialApp( title: 'My Layout App', home: Scaffold( appBar: AppBar( title: Text("My Layout App"), ), body: ListView( children: [ titlesection, ], )), ); } } The fix for this above issue, is to move the expanded widget inside a flex widget. Example below. import 'package:flutter/material.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { Widget titlesection = Container( padding: EdgeInsets.all(10.0), child: Row( children: [ Expanded( child: Column( children: [ Container( padding: EdgeInsets.only(bottom: 8.0), child: Text( "Some Lage Somthing", style: TextStyle(fontWeight: FontWeight.bold), ), ), Text("Someplace, Country") ], ), ), Icon(Icons.star) ], ), ); return MaterialApp( title: 'My Layout App', home: Scaffold( appBar: AppBar( title: Text("My Layout App"), ), body: ListView( children: [ titlesection, ], )), ); } }

Tags: Incorrect use of ParentDataWidget.



0 Comments
Login to comment.
Recent Comments

Be the first to Comment. You can ask a Query or Share your toughts or Just say thanks.




© 2018 - Fluttercentral | Email to me - Seven.srikanth@gmail.com