-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
parent child relation ship using flutter listview builder #2
Comments
I will have many textfields in both listviewbuilder but only update if it is related |
Hello @probegins, I am not sure to fully understand the result that you would want to achieve. Could you provide a repo to show some code? |
I have 2 list view builder in same screen First list view contains 6 textbox Second list view contains 3 textbox Now I am trying to enter a number 10 in first list view builder ( for instance ,I entered in 4th row). Now textbox will show number 10. If this textbox is related with second list view builder textbox ( say 2nd one), then number 10 will show in this textbox. Pls note down that if it doesn't have any relation, the number will not show in second list view builder. So both list view will show same number, if related. https://pasteboard.co/IcTYPNE.jpg I have uploaded an image, if you notice that image , you can see that it has 2 sections. Look at the number 13 in first column , in this row you can see a number 6 Now you look at the number 2 in last section , in this row you can see the same number 6 again. What ever I entered in first section appears here since itbhas relation. You can see that there are many numbers in first section such as 2 & 5 but that doesnt appear in second section since itbhas no relation.Hope you got it now I don't know listview builder widget is right for this scenario. I have also seen table widget but no idea which one provide result. As I have many rows I decided to use list view builder and managing state |
Hello @probegins , I've just added an example. Let me know if I understood correctly what you meant. Example name: 'Products catalog': |
Hello, when we launch screen we should have 2 section. products1 sectionitem_name quantiy price products2 sectionitem_name quantity price The above 2 will be the default look and feel when we open the page when we enter a number in products1 section , say I am going to enter 5 in apple row as quantity, that number should appear in product2 section if apple and apple1 are related. If it's related we get following output on the screen products1 sectionitem_name quantiy price products2 sectionitem_name quantity price The changes happens only in apple & apple1 row as per above screens. I am again going to enter quantity as 10 in bag row but think that it has no related item in products2 section, then the output will be products1 sectionitem_name quantiy price products2 sectionitem_name quantity price We can see that whatever entered early reaming same even if we change bag. Hope now it is clear. How second section knows what are the items it is related to first section, we need to find that row then we should be able to update only that row. |
It isn't how it works in the example I wrote? I've used the 'id' property of the product to establish a relation between fields in a different place. Pay attention to these methods: void addItem(int id) {
if (!cart.value.any((item) => item == id)) {
// Add the item to the cart
cart.addElement(id);
getItem(id).refreshTotal();
final item = catalog.value.firstWhere((item) => item.id == id);
// To disable the add button
item.added.value = true;
} else {
print('already in the cart');
}
}
void changeQuantity(int id, String value) {
final qnt = int.tryParse(value);
final item = catalog.value.firstWhere((item) => item.id == id);
if (qnt != null && qnt > 0) {
item.quantity.value = int.tryParse(value);
item.refreshTotal();
} else {
item.quantity.stream.addError('Insert a valid quantity.');
}
} In the firts part of the screen you have the catalog when you can add an item and set a quantity. In the |
Thanks we have following code
If I want to load data from API what are the changes in |
@gitflutter you need to create model class to deserialize the json resulted from the API. You can find an example on how you can achieve this in the Trivia example. You may want to give a look at this article where you can find a detailed explanation: "How to build a quiz game". |
Hi,
I am new to flutter and started to use your package for my current application.
I have an issue. I can explain how my interface is and what I am trying ti achieve.
I have 2 section(container) in my screen. The screen is divided into 2 parts. The first part contains a list view builder and second also contains listviewbuilder. I already have one to one relationship b/w data. What I mean here, When I try to change any data in first listview, it should show in second listview builder but only in realted field in second listview builder.
I can say that I have textfield controller in both listview builders. If I eneter a number in first listview builder textbox, that should capture and show in second listviewbuilder if it is related with first textbox controller. if there is no relation, it should not show. I am not getting an idea how to do relationship and get all data from both listviewbuilder when submit data.
I am getting data in bloc but I don'r know where to insert in second list view builder. HO can I make correct reltation ship b/w this
The text was updated successfully, but these errors were encountered: