i am trying to pass different parameters in ListTile widget using function, but i don't know how to do it,
here i how i am trying it,
Passing Parameter from widget;
Widget listSection =Container(
child: Row(
children: [
_listSectionMethod("TITLE 1", "hello i am subtitle two"),
_listSectionMethod("TITLE 2", "hello i am subtitle two"),
],
),
);
Method to use those parameters in listtile;
Card _listSectionMethod(String title,String subtitle){
return Card(
child:ListTile(
title:Text(title),
subtitle:Text(subtitle),
),
);
}
Expected result:
i am trying to show list tile with title and subtitle, on a card.
Error: RenderBox was not laid out
#Fayakon, i think you need to use Column (for vertical widgets) instead of Row (for horizontal widgets) to get get the desired result,
child: Column(
children: <Widget>[
_listSectionMethod("TITLE 1", "hello i am subtitle two"),
_listSectionMethod("TITLE 2", "hello i am subtitle two"),
],
)
Screenshot:
Hope this helps. Learn more about Flutter layouts here - https://flutter.dev/docs/development/ui/layout
Related
flutter How do I make the elements of List break to the second line after reaching the screen?
This is the problem:
[the problem1
this the code:
Wrap(
children: [
Row(
children: scoreKeeper,
),
],
),
You can directly add children inside wrap.. assuming scorekeeper is a list of widget
Wrap(
children: scoreKeeper,
),
I am quite new to Flutter and was trying to implement the CupertinoPicker Widget.
When I press a button I want to be able to replace the current CupertinoPicker with another one.
Unfortunately when I try this the text from the second UI is quite distorted.
Here are some images to help you understand my issue.
What exactly am I missing here?
Here is my code
Code on Github
Just wrap the Center widget with a Container widget. Here's a screenshot of the app and the code.
Widget _second() {
return Container(
child: Center(
child: CupertinoPicker(
selectionOverlay: null,
onSelectedItemChanged: (value) {},
itemExtent: 30,
children: [
Text("City 1"),
Text("City 2"),
Text("City 3"),
Text("City 4"),
Text("City 5"),
Text("City 6"),
Text("City 7"),
],
),
),
);
}
anyone know how can i get parent widget width ? i try to solve this problem on my UI below
here my widget tree
row
expanded
flex:8
row
column
container(
width : ???? // here i want to get width size of expanded flex: 8
Wrap(
children: [
Text('item A'),
Text('item B'),
Text('item C'),
Text('item D'),
],
),)
You can use LayoutBuilder, when you wrap the widget in it it will give you parent contraints
How to Put one icon in center of another icon like google map marker like below?
You should use "Stack" control in which you have to add the first icon with "Pin" and same add another with "Carry"
Widget getStack() {
return Stack(
children: <Widget>[
Center(
child: Icon(Icons.account_balance),
),
Center(
child: Icon(Icons.account_balance),
)
],
);
}
I am attempting to add vertical divider between the leading portion and the title of a ListTile.
I understand that Flutter now has a VerticalDivider widget, but I can't seem to get it to work properly with the ListTile. Example of what I am trying to do is attached.
This was tagged as a possible duplicate post, but it is not. Just because the other post has VerticalDivider in the title doesn't mean that it is asking the same question. Maybe the person who tagged it as a duplicate should actually read the post instead of just browse the title...
You can just use a Row widget inside the leading property of the ListTile
ListTile(
leading: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.add_shopping_cart),
VerticalDivider(),
],
),
title: Text("QUICK REFERENCE"),
),