class TestTab extends StatefulWidget {
final int pageIndex;
const TestTab({
Key? key,
required this.pageIndex,
}) : super(key: key);
@override
_TestTabState createState() => _TestTabState();
}
class _TestTabState extends State<TestTab> {
@override
Widget build(BuildContext context) {
Provider.of<BottomTabProvider>(context, listen: true);
return PopScope(
canPop: false,
child: SafeArea(
top: false,
child: CupertinoTabScaffold(
resizeToAvoidBottomInset: true,
tabBuilder: (context, index) {
switch (index) {
case 0:
return CupertinoTabView(
navigatorKey: kidsTabKey,
builder: (context) {
return const CupertinoPageScaffold(
child: Center(
child: Text("Screen1"),
));
},
);
case 1:
return CupertinoTabView(
builder: (context) {
return const CupertinoPageScaffold(
child: Center(
child: Text("Screen2"),
));
},
);
case 2:
return CupertinoTabView(
builder: (context) {
return const CupertinoPageScaffold(
child: Center(
child: Text("Screen3"),
));
},
);
}
return Container();
},
tabBar: CupertinoTabBar(
height: 50,
backgroundColor: const Color.fromARGB(255, 174, 218, 228),
activeColor: AppColors.lighPurpleColor,
inactiveColor: AppColors.blackColor,
currentIndex: 0,
onTap: (index) {
},
items: [
BottomNavigationBarItem(
icon: GestureDetector(
child: Container(
padding: const EdgeInsets.all(10),
decoration: const BoxDecoration(
color: Colors.transparent,
),
child: Image.asset(
Assets.kids,
color: Colors.black
),
),
),
label: "screen1",
),
BottomNavigationBarItem(
icon: GestureDetector(
child: Container(
padding: EdgeInsets.all(getHeight() * 0.008),
decoration: const BoxDecoration(
color: Colors.transparent,
),
child: Image.asset(
Assets.callHistory,
color: Colors.black
),
),
),
label: "screen2",
),
BottomNavigationBarItem(
icon: GestureDetector(
child: Container(
padding: EdgeInsets.all(getHeight() * 0.008),
decoration: const BoxDecoration(
color: Colors.transparent,
),
child: Image.asset(
Assets.profile,
color:Colors.black
),
),
),
label: "screen3",
),
],
),
),
),
);
}
}
Is there an existing issue for this?
Steps to reproduce
I was using WillPopScope widget with flutter version 3.0.5 and then I upgraded to 3.16.0 stable channel Now in latest version WillPopScope is deprecated and the new widget is introduced with the name of PopScope.
I am using CupertinoTabScaffold with tabbar in order to persist the bottomtab I am wrapping my CupertinoTabScaffold with PopScope and set the canPop to false it does not allow to kill the application but it removes the very first screen by tapping back button of android. Let's say I have three tabs tab1,tab2,tab3 and I have started application and I am in tab1 and there is screen 1 when I will tap on android back button it will remove the screen1 and show me the grey screen.
When I was using WillPopScope it was working as expected.
Expected results
I want to register a background task by tapping android back button and after registering i want to exit the application
Actual results
It removes the first screen of tab1 and shows the grey screen.
Code sample
Code sample
Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
verbose_logs.pdf
Flutter Doctor output
Doctor output