Cannot Navigate back in Scaffold AppBar Flutter

Hello everyone i am a beginner in Flutter Development, i want to switch pages using the arrow back icon on the ListCompetitionScreen to go to the homeScreen ( this is my default start screen ), but when I opened the application and move to ListCompetitionScreen and then I clicked on the arrow back icon from the ListCompetitionScreen to go to the homeScreen there was an error like this:

════════ Exception caught by gesture ═══════════════════════════════════════════
The following assertion was thrown while handling a gesture:
A page-based route cannot be completed using imperative api, provide a new list without the corresponding Page to Navigator.pages instead.
'package:flutter/src/widgets/navigator.dart':
package:flutter/…/widgets/navigator.dart:1
Failed assertion: line 3139 pos 7: '!pageBased || isWaitingForExitingDecision'

2

Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=2_bug.yml

#8      GestureRecognizer.invokeCallback
package:flutter/…/gestures/recognizer.dart:315
#9      TapGestureRecognizer.handleTapUp
package:flutter/…/gestures/tap.dart:652
#10     BaseTapGestureRecognizer._checkUp
package:flutter/…/gestures/tap.dart:309
#11     BaseTapGestureRecognizer.handlePrimaryPointer
package:flutter/…/gestures/tap.dart:242
#12     PrimaryPointerGestureRecognizer.handleEvent
package:flutter/…/gestures/recognizer.dart:670
#13     PointerRouter._dispatch
package:flutter/…/gestures/pointer_router.dart:98
#14     PointerRouter._dispatchEventToRoutes.<anonymous closure>
package:flutter/…/gestures/pointer_router.dart:143
#15     _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:633:13)
#16     PointerRouter._dispatchEventToRoutes
package:flutter/…/gestures/pointer_router.dart:141
#17     PointerRouter.route
package:flutter/…/gestures/pointer_router.dart:127
#18     GestureBinding.handleEvent
package:flutter/…/gestures/binding.dart:495
#19     GestureBinding.dispatchEvent
package:flutter/…/gestures/binding.dart:475
#20     RendererBinding.dispatchEvent
package:flutter/…/rendering/binding.dart:430
#21     GestureBinding._handlePointerEventImmediately
package:flutter/…/gestures/binding.dart:420
#22     GestureBinding.handlePointerEvent
package:flutter/…/gestures/binding.dart:383
#23     GestureBinding._flushPointerEventQueue
package:flutter/…/gestures/binding.dart:330
#24     GestureBinding._handlePointerDataPacket
package:flutter/…/gestures/binding.dart:299
#25     _invoke1 (dart:ui/hooks.dart:328:13)
#26     PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:429:7)
#27     _dispatchPointerDataPacket (dart:ui/hooks.dart:262:31)
(elided 2 frames from class _AssertionError)
Handler: "onTap"
Recognizer: TapGestureRecognizer#8d8d1
    debugOwner: GestureDetector
    state: possible
    won arena
    finalPosition: Offset(41.1, 51.0)
    finalLocalPosition: Offset(33.1, 19.0)
    button: 1
    sent tap down
════════════════════════════════════════════════════════════════════════════════




can anyone help me to find the solution of this problem ?

here is the detail of my code :

//MyApp

class MyApp extends StatefulWidget {
  final int initialPageIndex;

  const MyApp({super.key, this.initialPageIndex = 0});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  late int _pageIndex;

  @override
  void initState() {
    super.initState();
    _pageIndex = widget.initialPageIndex;
  }

  final List<Widget> _pages = [
    const HomeScreen(),
    const ListCompetitions(),
    const ScanQrCode(),
    const CalendarCompetition(),
    const ProfileUser(),
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      bottomNavigationBar: _pageIndex == 2
          ? null
          : BottomNavBar(
              currentIndex: _pageIndex,
              onTap: (index) {
                setState(() {
                  _pageIndex = index;
                });
              },
            ),
      body: _pages[_pageIndex],
    );
  }
}


//ListCompetitionsScreen


class ListCompetitions extends StatefulWidget {
  const ListCompetitions({super.key});

  @override
  State<ListCompetitions> createState() => _ListCompetitionsState();
}

class _ListCompetitionsState extends State<ListCompetitions> {
  final ScrollController _scrollController = ScrollController();

  @override
  void initState() {
    super.initState();

    // Add scroll listener
    _scrollController.addListener(_scrollListener);
  }

  @override
  void dispose() {
    _scrollController.dispose();
    super.dispose();
  }

  void _scrollListener() {
    if (_scrollController.position.pixels ==
        _scrollController.position.maxScrollExtent) {
      Provider.of<GetCompetitionController>(context, listen: false).loadMore();
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Colors.white,
        elevation: 0,
        leading: IconButton(
          icon: const Icon(
            Icons.arrow_back,
            color: Colors.black,
          ),
          onPressed: () {
            Navigator.pushReplacement(
              context,
              MaterialPageRoute(
                builder: (context) => const MyApp(initialPageIndex: 0),
              ),
            );
          },
        ),
        title: Text(
          'List Competitions',
          style: GoogleFonts.poppins(
            color: Colors.black,
            fontSize: 20,
            fontWeight: FontWeight.w500,
          ),
        ),
        centerTitle: true,
      ),
.....
the rest of my code

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật