Can you please tell me if it is possible to create a ListView
but always have 1 fixed item at the end of the list, thus allowing a new card to be added. As shown in the screenshot below. There is a regular list of cards and at the end a card with an Add New Point
button, when clicked, an action occurs (adding a new element to the end of the list).
If you know how to implement such an element as Add New Poynt, please tell me, I will be grateful.
CodePudding user response:
This is only logic please try it your own widget. Because I have not laptop.
**This code has syntax error please chaeck it because i have not laptop **
int howManyWidgetDraw = 5;
ListView.builder(
itemCount: howManyWidgetDraw,
itemBuilder: (BuildContext context,int
index){
if(howManyWidgetDraw==index.length){
return InkWell(
onTap(){
howManyWidgetDraw=howManyWidgetDraw 1;
//Call setstate method.
},
child: Text("last element print"));
}
else{
return Text("first four element");
}
}
),
);
Have any issue please ask me?
CodePudding user response:
You can increase itemLength
by 1 and while check if the index is last one, provide your fixed widget.
ListView.builder(
itemCount: itemLength 1,
itemBuilder: (context, index) {
if (index == itemLength) {
return Text("last Item");
}
return Text("item $index");
},
),