0
0
Fluttermobile~20 mins

Dismissible for swipe actions in Flutter - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Dismissible Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
ui_behavior
intermediate
2:00remaining
What happens when you swipe a Dismissible widget?
Consider a Flutter app with a Dismissible widget wrapping a ListTile. What is the default behavior when the user swipes the item from right to left?
Flutter
Dismissible(
  key: Key('item1'),
  child: ListTile(title: Text('Swipe me')),
  onDismissed: (direction) {
    print('Item dismissed');
  },
)
ANothing happens; the swipe gesture is ignored.
BThe item is removed from the list and onDismissed callback is called.
CThe item is highlighted but remains visible; onDismissed is not called.
DThe app crashes because Dismissible requires a background widget.
Attempts:
2 left
💡 Hint
Think about what Dismissible is designed to do when swiped.
📝 Syntax
intermediate
2:00remaining
Which code correctly implements a Dismissible with a red background on swipe?
You want to show a red background behind the item when swiped. Which code snippet correctly sets this up?
A
Dismissible(
  key: Key('item2'),
  background: Container(color: Colors.red),
  child: ListTile(title: Text('Swipe me')),
)
B
Dismissible(
  key: Key('item2'),
  background: Colors.red,
  child: ListTile(title: Text('Swipe me')),
  onDismissed: (_) {},
)
C
)
,}{ )_( :dessimsiDno  
,))'em epiwS'(txeT :eltit(eliTtsiL :dlihc  
,)der.sroloC :roloc(reniatnoC :dnuorgkcab  
,)'2meti'(yeK :yek  
(elbissimsiD
D
Dismissible(
  key: Key('item2'),
  background: Container(color: Colors.red),
  child: ListTile(title: Text('Swipe me')),
  onDismissed: (_) {},
)
Attempts:
2 left
💡 Hint
The background property expects a widget, not a color directly.
lifecycle
advanced
2:00remaining
What happens if you reuse the same Key for multiple Dismissible widgets?
In a list of Dismissible widgets, what is the effect of assigning the same Key to more than one Dismissible?
AFlutter throws an exception because keys must be unique among siblings.
BThe widgets work fine; keys are optional for Dismissible.
COnly the first Dismissible responds to swipe; others ignore gestures.
DThe app silently ignores duplicate keys and behaves normally.
Attempts:
2 left
💡 Hint
Keys help Flutter identify widgets uniquely in the widget tree.
navigation
advanced
2:00remaining
How to navigate after dismissing an item in a Dismissible?
You want to navigate to a new screen after an item is dismissed. Where should you place the navigation code?
AInside the build method of the Dismissible widget.
BInside the background widget of the Dismissible.
CInside the onDismissed callback after removing the item from the list.
DInside the initState method of the parent widget.
Attempts:
2 left
💡 Hint
Think about when the dismissal action completes.
🔧 Debug
expert
2:00remaining
Why does the Dismissible widget not dismiss when swiped?
You have this code but swiping the item does not remove it or call onDismissed: Dismissible( key: Key('item3'), child: ListTile(title: Text('Swipe me')), onDismissed: (direction) { print('Dismissed'); }, ) What is the most likely cause?
AThe parent list is not updating its data source to remove the dismissed item.
BThe key is missing from the Dismissible widget.
CThe onDismissed callback is empty and does nothing.
DThe child widget is not a ListTile.
Attempts:
2 left
💡 Hint
Dismissible removes the widget visually but the list must update to reflect the change.