Reputation: 21
Page skips while navigating through device back button.
import 'package:flutter/material.dart';
import 'package:modal_progress_hud/modal_progress_hud.dart';
class Attendance extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return AttendanceCalendar();
}
}
class AttendanceCalendar extends State<Attendance> {
bool isAsync = false;
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: _onBackButtonPressed,
child: ModalProgressHUD(
inAsyncCall: isAsync,
child: Scaffold(
appBar: AppBar(
title: Text("Attendance");
),
body: Container(),
),
),
);
}
void _onBackButtonPressed() {
Navigator.pop(context);
}
}
Upvotes: 2
Views: 1194
Reputation: 190
If you use MaterialApp() as root widget on this page as well as previous pages so pages were loading in the same Material App Space. Then back button press navigating skips between the same material apps. So recommend you to use Scaffold() as a root widget.
Upvotes: 1