Intermediate Flutter
Q79 / 100

What is the purpose of the WillPopScope widget in Flutter?

Correct! Well done.

Incorrect.

The correct answer is B) Intercepting the Android back button or navigation pop gesture to run custom logic or confirm before leaving the screen

B

Correct Answer

Intercepting the Android back button or navigation pop gesture to run custom logic or confirm before leaving the screen

Explanation

WillPopScope wraps a route and intercepts pop events (Android back button, navigation gesture). The onWillPop callback returns a Future<bool> — returning false prevents the pop. In Flutter 3.12+, prefer PopScope with canPop and onPopInvoked.

Progress
79/100