Repository: mobxjs/mobx.dart

Issue:
analyzer version bump to `>=4.4.0 <6.2.0`
Describe the changes proposed in this Pull Request.

If the PR fixes a specific issue, reference the issue with **`Fixes #`**.
Fixes #929, #928 

---
## Pull Request Checklist


- [x] If the changes are being made to code, ensure the **version in `pubspec.yaml`** is updated. 
- [x] Increment the **`major`/`minor`/`patch`/`patch-count`**, depending on the complexity of change
- [x] Add the necessary **unit tests** to ensure the coverage does not drop
- [x] Update the **Changelog** to include all changes made in this PR, organized by version
- [x] Run the **`melo run set_version` command** from the root directory
- [x] Include the **necessary reviewers** for the PR
- [x] Update the docs if there are any API changes or additions to functionality

Support for analyzer 6.0.0

chore: analyzer ^6.2.0
chore: analyzer ^6.2.0


Discussion: Since there won't be breaking changes until analyzer 7.0.0, only fixes and deprecations, I'd say we could have `<7.0.0` instead.
## [Codecov](https://app.codecov.io/gh/mobxjs/mobx.dart/pull/930?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mobxjs) Report
> Merging [#930](https://app.codecov.io/gh/mobxjs/mobx.dart/pull/930?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mobxjs) (3cae66d) into [master](https://app.codecov.io/gh/mobxjs/mobx.dart/commit/6e6378c64525f71b0a373b1dcb641243b675b72a?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mobxjs) (6e6378c) will **increase** coverage by `1.00%`.
> Report is 4 commits behind head on master.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://app.codecov.io/gh/mobxjs/mobx.dart/pull/930/graphs/tree.svg?width=650&height=150&src=pr&token=YjGMFvwbrl&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mobxjs)](https://app.codecov.io/gh/mobxjs/mobx.dart/pull/930?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mobxjs)

```diff
@@             Coverage Diff             @@
##           master      #930      +/-   ##
===========================================
+ Coverage   98.99%   100.00%   +1.00%     
===========================================
  Files          56         5      -51     
  Lines        1987        97    -1890     
===========================================
- Hits         1967        97    -1870     
+ Misses         20         0      -20     
```

| [Flag](https://app.codecov.io/gh/mobxjs/mobx.dart/pull/930/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mobxjs) | Coverage Δ | |
|---|---|---|
| [flutter_mobx](https://app.codecov.io/gh/mobxjs/mobx.dart/pull/930/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mobxjs) | `100.00% <ø> (ø)` | |
| [mobx](https://app.codecov.io/gh/mobxjs/mobx.dart/pull/930/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mobxjs) | `?` | |
| [mobx_codegen](https://app.codecov.io/gh/mobxjs/mobx.dart/pull/930/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mobxjs) | `?` | |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mobxjs#carryforward-flags-in-the-pull-request-comment) to find out more.

[see 51 files with indirect coverage changes](https://app.codecov.io/gh/mobxjs/mobx.dart/pull/930/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mobxjs)

------

[Continue to review full report in Codecov by Sentry](https://app.codecov.io/gh/mobxjs/mobx.dart/pull/930?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mobxjs).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mobxjs)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://app.codecov.io/gh/mobxjs/mobx.dart/pull/930?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mobxjs). Last update [95c1506...3cae66d](https://app.codecov.io/gh/mobxjs/mobx.dart/pull/930?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mobxjs). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mobxjs).

+1
not compatible with `freezed`
<img width="982" alt="image" src="https://github.com/mobxjs/mobx.dart/assets/12999702/4d4be984-0672-4c64-afd6-0ec16ae8b807">

`dependency_overrides` doesn't help; forced `analyzer: ^6.0.0` leads to even stranger generation bugs:

<img width="1047" alt="image" src="https://github.com/mobxjs/mobx.dart/assets/12999702/d9503883-6908-4d84-99bd-a4749982d7e0">

do you have any news about this please ?
+1
+1

Fix patch:
diff --git a/mobx_codegen/CHANGELOG.md b/mobx_codegen/CHANGELOG.md
index 5888395f..6f58bd96 100644
--- a/mobx_codegen/CHANGELOG.md
+++ b/mobx_codegen/CHANGELOG.md
@@ -1,3 +1,9 @@
+## 2.4.0
+
+- Require `analyzer: ^5.12.0`
+- Support the latest package:analyzer
+- Require Dart 3.0
+
 ## 2.3.0
 
 - Adds `@alwaysNotify` annotation support for creating always notify observables. [@amondnet](https://github.com/amondnet) in [#907](https://github.com/mobxjs/mobx.dart/pull/907)
diff --git a/mobx_codegen/lib/src/template/util.dart b/mobx_codegen/lib/src/template/util.dart
index 73363250..fe980286 100644
--- a/mobx_codegen/lib/src/template/util.dart
+++ b/mobx_codegen/lib/src/template/util.dart
@@ -22,12 +22,14 @@ class AsyncMethodChecker {
       method.returnType.isDartAsyncFuture ||
       (method.isAsynchronous &&
           !method.isGenerator &&
+          // ignore: deprecated_member_use
           method.returnType.isDynamic);
 
   bool returnsStream(MethodElement method) =>
       _checkStream.isAssignableFromType(method.returnType) ||
       (method.isAsynchronous &&
           method.isGenerator &&
+          // ignore: deprecated_member_use
           method.returnType.isDynamic);
 }
 
diff --git a/mobx_codegen/lib/src/type_names.dart b/mobx_codegen/lib/src/type_names.dart
index d6c1e0db..7c1cdcb9 100644
--- a/mobx_codegen/lib/src/type_names.dart
+++ b/mobx_codegen/lib/src/type_names.dart
@@ -35,7 +35,6 @@ class LibraryScopedNameFinder {
     // Reverse each import's export namespace so we can map elements to their
     // library-local names. Note that the definedNames include a prefix if there
     // is one.
-    // ignore: deprecated_member_use
     for (final import in library.libraryImports) {
       for (final entry in import.namespace.definedNames.entries) {
         _namesByElement[entry.value] = entry.key;
@@ -75,14 +74,12 @@ class LibraryScopedNameFinder {
   ///
   /// The returned string will include import prefixes on all applicable types.
   String _getDartTypeName(DartType type) {
-    // ignore: deprecated_member_use
-    var typeElement = type.element2;
+    var typeElement = type.element;
     if (type is FunctionType) {
       // If we're dealing with a typedef, we let it undergo the standard name
       // lookup. Otherwise, we special case the function naming.
       if (type.alias?.element is TypeAliasElement) {
-        // ignore: deprecated_member_use
-        typeElement = type.alias!.element.aliasedElement?.enclosingElement3;
+        typeElement = type.alias!.element.aliasedElement?.enclosingElement;
       } else {
         return _getFunctionTypeName(type);
       }
diff --git a/mobx_codegen/lib/version.dart b/mobx_codegen/lib/version.dart
index 855f13a8..5c81252f 100644
--- a/mobx_codegen/lib/version.dart
+++ b/mobx_codegen/lib/version.dart
@@ -1,4 +1,4 @@
 // Generated via set_version.dart. !!!DO NOT MODIFY BY HAND!!!
 
 /// The current version as per `pubspec.yaml`.
-const version = '2.2.0';
+const version = '2.4.0';
diff --git a/mobx_codegen/pubspec.yaml b/mobx_codegen/pubspec.yaml
index a437ed68..6e988cdd 100644
--- a/mobx_codegen/pubspec.yaml
+++ b/mobx_codegen/pubspec.yaml
@@ -1,15 +1,15 @@
 name: mobx_codegen
 description: Code generator for MobX that adds support for annotating your code with @observable, @computed, @action and also creating Store classes.
-version: 2.3.0
+version: 2.4.0
 
 homepage: https://github.com/mobxjs/mobx.dart
 issue_tracker: https://github.com/mobxjs/mobx.dart/issues
 
 environment:
-  sdk: ">=2.13.0 <3.0.0"
+  sdk: ^3.0.0
 
 dependencies:
-  analyzer: ">=4.4.0 <6.0.0"
+  analyzer: ">=5.12.0 <7.0.0"
   build: ^2.2.1
   build_resolvers: ^2.0.6
   meta: ^1.3.0
@@ -23,5 +23,5 @@ dev_dependencies:
   coverage: ^1.0.4
   lints: ^2.0.0
   logging: ^1.0.2
-  mocktail: ^0.3.0
+  mocktail: ^1.0.0
   test: ^1.20.1


Test patch:
diff --git a/mobx_codegen/test/data/valid_output_annotation_store_config_has_to_string.dart b/mobx_codegen/test/data/valid_output_annotation_store_config_has_to_string.dart
index 55ac955e..a151b3b3 100644
--- a/mobx_codegen/test/data/valid_output_annotation_store_config_has_to_string.dart
+++ b/mobx_codegen/test/data/valid_output_annotation_store_config_has_to_string.dart
@@ -1,6 +1,6 @@
 // GENERATED CODE - DO NOT MODIFY BY HAND
 
-part of generator_sample;
+part of 'generator_sample.dart';
 
 // **************************************************************************
 // StoreGenerator
diff --git a/mobx_codegen/test/util_test.dart b/mobx_codegen/test/util_test.dart
index 19a5def6..e5637902 100644
--- a/mobx_codegen/test/util_test.dart
+++ b/mobx_codegen/test/util_test.dart
@@ -20,6 +20,7 @@ MockMethod mockFutureMethod({
   bool isGenerator = false,
 }) {
   final returnType = MockType();
+  // ignore: deprecated_member_use
   when(() => returnType.isDynamic).thenReturn(returnsDynamic);
   when(() => returnType.isDartAsyncFuture).thenReturn(returnsFuture);
   when(() => returnType.isDartAsyncFutureOr).thenReturn(returnsFutureOr);
@@ -37,6 +38,7 @@ MockMethod mockStreamMethod({
   bool returnsDynamic = false,
 }) {
   final returnType = MockType();
+  // ignore: deprecated_member_use
   when(() => returnType.isDynamic).thenReturn(returnsDynamic);
 
   final method = MockMethod();