felangel / felangel/flow_builder
Android back button closing app instead of popping page on Android 16
- Dominant language
- Dart
- Stars
- 416
- Forks
- 68
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
In our app we have a `FlowBuilder` which is directing the user either to the login page or directly to the home page of the app. Within the home page and its sub-pages, we sometimes push pages that can be popped again using the back button.
Now, up to now everything worked fine. But suddenly on Android 16 this functionality breaks. Pressing the (hardware) back button or doing the Android swipe-back would now suddenly close the app, whereas on e.g. Android 15 it doesn't.
I know that using `Navigator.of(context, rootNavigator: true)` solves the problem. But I ask myself if that is the desired solution here!?
Example to reproduce
```dart
import 'package:flow_builder/flow_builder.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(title: 'Flutter Demo', home: const HomePage());
}
}
class HomePage extends StatelessWidget {
const HomePage({super.key});
@override
Widget build(BuildContext context) {
// option 1: uncomment this for not using flow builder. this works fine on android 15 + 16
// return FirstPage();
// option 2: using flow builder here breaks the Android back button on Android version 16+, while on Android 15 it works fine
return FlowBuilder(
// just a simple flow builder which has 1 page
state: 0,
onGeneratePages: (state, pages) => [MaterialPage(child: FirstPage())],
);
}
}
class FirstPage extends StatelessWidget {
const FirstPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text('First page'),
),
body: Center(
child: ElevatedButton(
onPressed: () {
Navigator.of(context).push(MaterialPageRoute(builder: (context) => SecondPage()));
},
child: Text('Push page'),
),
),
);
}
}
class SecondPage extends StatelessWidget {
const SecondPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text('Second page'),
),
body: Center(child: Text('This is the second page')),
);
}
}
```
**To Reproduce**
Steps to reproduce the behavior:
1. Execute the code from above on an Android 15 (or below) device/emulator.
2. Click on the "Push page" button, and see how you land on the second page
3. Press the back button of the phone, or use the swipe back gesture
4. See how you land on the first page again
5. Now, execute the code from above on an **Android 16** device/emulator.
2. Click on the "Push page" button, and see how you land on the second page
3. Press the back button of the phone, or use the swipe back gesture
4. See how the app is closed completely
**Expected behavior**
The desired behavior would be that pressing the back button on a pushed page wouldn't close the entire app.
**Screenshots**
Android 15: expected behavior

Android 16: unexpected behavior

**Logs **
Run `flutter analyze` and attach any output of that command below.
If there are any analysis errors, try resolving them before filing this issue.
```
Resolving dependencies...
Downloading packages...
characters 1.4.0 (1.4.1 available)
flutter_lints 5.0.0 (6.0.0 available)
lints 5.1.1 (6.0.0 available)
material_color_utilities 0.11.1 (0.13.0 available)
meta 1.16.0 (1.17.0 available)
test_api 0.7.6 (0.7.7 available)
Got dependencies!
6 packages have newer versions incompatible with dependency constraints.
Try `flutter pub outdated` for more information.
Analyzing back_navigation_test...
No issues found! (ran in 0.9s)
```
Paste the output of running `flutter doctor -v` here.
```
[✓] Flutter (Channel stable, 3.35.7, on macOS 26.0.1 25A362 darwin-arm64, locale en-IT) [443ms]
• Flutter version 3.35.7 on channel stable at /Users/work/fvm/versions/3.35.7
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision adc9010625 (2 weeks ago), 2025-10-21 14:16:03 -0400
• Engine revision 035316565a
• Dart version 3.9.2
• DevTools version 2.48.0
• Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios,
cli-animations, enable-lldb-debugging
[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0) [1,433ms]
• Android SDK at /Users/Shared/Android/sdk
• Emulator version 36.2.12.0 (build_id 14214601) (CL:N/A)
• Platform android-36, build-tools 36.0.0
• ANDROID_HOME = /Users/Shared/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
This is the JDK bundled with the latest Android Studio installation on this machine.
To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
• Java version OpenJDK Runtime Environment (build 21.0.6+-13391695-b895.109)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 16.4) [944ms]
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 16F6
• CocoaPods version 1.16.2
[✓] Chrome - develop for the web [23ms]
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2025.1) [23ms]
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 21.0.6+-13391695-b895.109)
[✓] IntelliJ IDEA Community Edition (version 2025.2.1) [22ms]
• IntelliJ at /Users/work/Applications/IntelliJ IDEA Community Edition.app
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
[✓] VS Code (version 1.104.1) [7ms]
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension can be installed from:
🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[✓] Connected device (4 available) [6.5s]
• sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64 • Android 16 (API 36) (emulator)
• sdk gphone64 arm64 (mobile) • emulator-5556 • android-arm64 • Android 15 (API 35) (emulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 26.0.1 25A362 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 142.0.7444.60
[✓] Network resources [240ms]
• All expected network resources are available.
• No issues found!
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.