Flutter setting orientation to landscappe redirects page to main app

I have to change the orientation in a specified page to DeviceOrientation.landscapeLeft.
But when i do this on the page the orientation changes and when the ui is rendered it immediately changes to the main page.
And then the app go’s back to the first page.
It does not seem to mater wat i return in the build it always redirects.
I get no error.

This is the code of the landscape screen and the main screen.

class _ConsumptionExpandedScreenState extends State<ConsumptionExpandedScreen>
    with WidgetsBindingObserver {
@override
  void initState() {
    super.initState();

    WidgetsBinding.instance.addObserver(this);
    WidgetsFlutterBinding.ensureInitialized();
    // Lock orientation to landscape left
    _setLandscapeOrientation();
   
  }
  @override
  void dispose() {
    logger.d("In the dispose function of the expanded screen");
    // Reset orientation when leaving the screen
    SystemChrome.setPreferredOrientations([
      DeviceOrientation.portraitUp,
    ]);
    WidgetsBinding.instance.removeObserver(this);
    super.dispose();
  }

  @override
  void didChangeAppLifecycleState(AppLifecycleState state) {
    if (state == AppLifecycleState.resumed) {
      _setLandscapeOrientation();
    }
  }

  void _setLandscapeOrientation() {
    SystemChrome.setPreferredOrientations([
      DeviceOrientation.landscapeLeft,
    ]);
  }

  @override
  Widget build(BuildContext context) {

      double screenWidth = MediaQuery.of(context).size.width;
      double screenHeight = MediaQuery.of(context).size.height;
      logger.d(
          "Expanded consumption the current size(width : height) is $screenWidth : $screenHeight");
...


class _MainAppState extends State<MainApp> with WidgetsBindingObserver {

  Locale myLocale = const Locale('en', 'US');

  @override
  void didChangeAppLifecycleState(AppLifecycleState state) {
    // Handle app lifecycle changes if needed
  }

  @override
  void didChangeMetrics() {
    final newSize = WidgetsBinding.instance.window.physicalSize;
    logger.d("New size: ${newSize.width} : ${newSize.height}");
    // Handle orientation changes if needed
    setState(() {}); // Trigger rebuild to adjust layout
  }

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

    _loadData();
  }

  void _loadData() async {
    final prefs = await SharedPreferences.getInstance();
    indexLanguage = prefs.getInt(langIndexKey);

    // print("The number of the index $indexLanguage");
    if (indexLanguage != null) {}
    setState(() {});
  }

  @override
  void dispose() {
    // _adapterStateStateSubscription.cancel();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return ChangeNotifierProvider<ValueChangeProvider>(
      create: (context) => ValueChangeProvider(),
      child: Consumer<ValueChangeProvider>(
        builder: (context, valueChangeProvider, _) {
          logger.d("The main screen ");
          double screenWidth = MediaQuery.of(context).size.width;
          double screenHeight = MediaQuery.of(context).size.height;
          logger.d(
              "The current size(width : height) is $screenWidth : $screenHeight");
          updatePaddingValues(context);

          return PaddingConfig(
            sidePadding: globalPaddingSide,
            topPadding: paddingTop,
            topHeaderPadding: paddingHeaderTop,
            child: MaterialApp(
              color: AppColors.backgroundColor,
              navigatorObservers: [
                BluetoothAdapterStateObserver(valueChangeProvider),
                routeObserver
              ],
              localizationsDelegates: AppLocalizations.localizationsDelegates,
              supportedLocales: AppLocalizations.supportedLocales,
              locale: valueChangeProvider.currentLocale,
              theme: lightTheme,
              debugShowCheckedModeBanner: false,
              initialRoute: initialAppRoute,
              routes: AppRoutes.routes,
            ),
          );
        },
      ),
    );
  }
}

I have tried to change the rotation before entering this page but it does not matter on wat page it is, it always redirects to the mainApp page

this is the log of what happens when i push this page with the navigation.

I/flutter (18518): [D]  Expanded consumption the current size(width : height) is 360.0 : 708.0
I/flutter (18518): [D]  The main screen 
I/flutter (18518): [D]  The current size(width : height) is 672.0 : 360.0
I/flutter (18518): [D]  In the pairing list screen 
I/flutter (18518): [D]  Expanded consumption the current size(width : height) is 672.0 : 360.0
I/flutter (18518): [D]  Going to the pairing list
I/flutter (18518): [D]  In the pairing list screen 
I/flutter (18518): [D]  Expanded consumption the current size(width : height) is 672.0 : 360.0
I/flutter (18518): [D]  The main screen 
I/flutter (18518): [D]  The current size(width : height) is 360.0 : 708.0
I/flutter (18518): [D]  In the pairing list screen 
I/flutter (18518): [D]  In the pairing list screen 
I/flutter (18518): [D]  Expanded consumption the current size(width : height) is 360.0 : 708.0
I/flutter (18518): [D]  Going to the pairing list
I/flutter (18518): [D]  In the pairing list screen 
I/flutter (18518): [D]  In the pairing list screen 

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