How to solve: Issue with Getx 4.6.1

Question

Asked by Asif S on January 02, 2022 (source).

After adding a get:^4.6.1 I got the below error.

Code:

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return GetMaterialApp(
      title: 'Flutter web One',
      home: HomePage(),
    );
  }
}

Error:

  const CupertinoApp({

        ^^^^^^^^^^^^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/get-4.6.1/lib/get_navigation/src/root/get_material_app.dart:275:17: Error: No named parameter with the name 'useInheritedMediaQuery'.
                useInheritedMediaQuery: useInheritedMediaQuery,
                ^^^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/material/app.dart:217:9: Context: Found this candidate, but the arguments don't match.
  const MaterialApp.router({

        ^^^^^^^^^^^^^^^^^^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/get-4.6.1/lib/get_navigation/src/root/get_material_app.dart:322:17: Error: No named parameter with the name 'useInheritedMediaQuery'.
                useInheritedMediaQuery: useInheritedMediaQuery,

                ^^^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/material/app.dart:166:9: Context: Found this candidate, but the arguments don't match.
  const MaterialApp({
        ^^^^^^^^^^^

and also if I try to downgrade getx version 4.6.1 to 4.3.8 still i am getting the same error and in the error, it shows get-4.6.1 version.

Answer

Question answered by Md. A (source).

The above problem is happening in get version >= 4.6.0. Use the exact version below 4.6.0 withing using ^ sign, which upgrades the package to the maximum compatible version.

In pubspec.yaml use get package like below:

get: 4.5.1     #Don't use ^
FLUTTER FLUTTER-GETX
SHARE: