【问题标题】:When i click phone button it goes to the app first page not the last one in flutter当我点击电话按钮时,它会转到应用程序的第一页,而不是最后一页
【发布时间】:2023-02-25 18:53:35
【问题描述】:

我的应用程序中有多个屏幕,但是当我单击电话后退按钮时,它会转到第一页而不是堆栈中的最后一页。将流行不工作

@overrideWidget build(BuildContext context) {   // double _width = MediaQuery.of(context).size.width;
return Scaffold(
  backgroundColor: Colors.white,
  appBar: AppBar(
    elevation: 0,
    backgroundColor: Colors.white,
    leading: IconButton(
      onPressed: (){
        Navigator.pop(context);
      },
      icon: const Icon(Icons.arrow_back_ios , color: Colors.black,),
    ),
    title: const Text('Now Playing',style: TextStyle(color: Colors.black,fontWeight: FontWeight.w800),),
  ),
  body: SafeArea(
    child: Container(
      padding: const EdgeInsets.all(30),
      child: Column(
        children: [
          Container(
            width: MediaQuery.of(context).size.width,
            height: MediaQuery.of(context).size.height * 0.2,
            padding: const EdgeInsets.all(20),
            alignment: Alignment.center,
            decoration: const BoxDecoration(
              borderRadius: BorderRadius.all(Radius.circular(20)),
              color: Color.fromRGBO(10, 91, 144, 1),
              boxShadow: [
                BoxShadow(
                  blurRadius: 1,
                  offset: Offset(0,2),
                  color: Colors.black12
                ),
              ]
            ),

【问题讨论】:

  • 你如何导航,请在这里分享你的代码。
  • 我编辑我的问题请看
  • 您看到的代码是我应用程序的最后一页,但是当我按下电话后退按钮时,它导航到第一个屏幕而不是内存堆栈中的最后一个屏幕

标签: android flutter


【解决方案1】:

请分享您如何导航到其他屏幕,也许您正在使用 pushReplacement 它将用新屏幕替换当前屏幕

【讨论】:

  • 我没有使用 pushReplacement
  • 代码在上面你可以看到
  • 我正在使用这个 Navigator.push(context, MaterialPageRoute(builder: (context)=>AudioScreen( qari: widget.qari, index: index+1, list: surah, ) ));
  • 您至少应该分享所有负责推送路线的代码,正如您在上一条评论中所说,您似乎只有一个界面,分享所有必要的代码以便我可以帮助您
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-08-28
  • 1970-01-01
  • 2012-11-29
相关资源
最近更新 更多