The key is Key('item') which is constant and not unique per item, causing issues in lists.
Step 2: Verify other parts
The onDismissed callback exists, child is a ListTile, and index is assumed defined, so no issues there.
Final Answer:
The key is not unique for each item -> Option A
Quick Check:
Keys must be unique per Dismissible [OK]
Hint: Keys must be unique strings or objects per item [OK]
Common Mistakes:
Using same key for all items
Ignoring key importance in lists
Assuming onDismissed is optional
5. You want to show a red background with a trash icon when swiping a Dismissible item to the left. Which code snippet correctly implements this?
hard
A. background: Container(color: Colors.red)
B. background: Container(color: Colors.red, child: Icon(Icons.delete, color: Colors.white))
C. background: Container(color: Colors.white, child: Icon(Icons.delete, color: Colors.red))
D. background: Icon(Icons.delete, color: Colors.red)
Solution
Step 1: Understand background property
The background expects a widget behind the item during swipe, usually a colored container with an icon.
Step 2: Check each option's correctness
The snippet with Container(color: Colors.red, child: Icon(Icons.delete, color: Colors.white)) provides a red background with a visible white trash icon. Others lack a container, the icon, or use colors that do not produce a red background with a visible trash icon.
Final Answer:
background: Container(color: Colors.red, child: Icon(Icons.delete, color: Colors.white)) -> Option B
Quick Check:
Red container + white icon = correct swipe background [OK]
Hint: Use Container with color and Icon for swipe background [OK]
Common Mistakes:
Using icon alone without container
Wrong colors making icon invisible
Missing icon in background
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.