[roll] Update third-party dart packages

Roller-URL: https://ci.chromium.org/b/8865790910536517632
Cq-Cl-Tag: roller-builder:dart-flutter-roller-post-submit
Cq-Cl-Tag: roller-bid:8865790910536517632
CQ-Do-Not-Cancel-Tryjobs: true
Change-Id: I98d6b8c3d64861558c86a5f8859318ee2e667c67
Reviewed-on: https://fuchsia-review.googlesource.com/c/third_party/dart-pkg/+/441542
Reviewed-by: GI Roller <global-integration-roller@fuchsia-infra.iam.gserviceaccount.com>
Commit-Queue: GI Roller <global-integration-roller@fuchsia-infra.iam.gserviceaccount.com>
diff --git a/mockito/BUILD.gn b/mockito/BUILD.gn
index dfaa5fb..13f23d9 100644
--- a/mockito/BUILD.gn
+++ b/mockito/BUILD.gn
@@ -1,4 +1,4 @@
-# This file is generated by importer.py for mockito-4.1.2
+# This file is generated by importer.py for mockito-4.1.3
 
 import("//build/dart/dart_library.gni")
 
diff --git a/mockito/CHANGELOG.md b/mockito/CHANGELOG.md
index f49c8cf..54a02e5 100644
--- a/mockito/CHANGELOG.md
+++ b/mockito/CHANGELOG.md
@@ -1,3 +1,10 @@
+## 4.1.3
+
+* Allow using analyzer 0.40.
+* `throwOnMissingStub` accepts an optional argument, `exceptionBuilder`, which
+  will be called to build and throw a custom exception when a missing stub is
+  called.
+
 ## 4.1.2
 
 * Introduce experimental code-generated mocks. This is primarily to support
diff --git a/mockito/NULL_SAFETY_README.md b/mockito/NULL_SAFETY_README.md
index 82dddce..a1402c9 100644
--- a/mockito/NULL_SAFETY_README.md
+++ b/mockito/NULL_SAFETY_README.md
@@ -97,9 +97,10 @@
 }
 ```
 
-We need to then run build_runner to generate the new library:
+We need to depend on build_runner. Add a dependency in the `pubspec.yaml` file,
+under `dev_dependencies`: something like `build_runner: ^1.10.0`.
 
-<!-- TODO(srawlins): Note about depending on build_runner. Test workflow. -->
+The final step is to run build_runner in order to generate the new library:
 
 ```shell
 pub run build_runner build
diff --git a/mockito/README.md b/mockito/README.md
index 77fa978..a6c8a38 100644
--- a/mockito/README.md
+++ b/mockito/README.md
@@ -166,7 +166,7 @@
 If an argument other than an ArgMatcher (like [`any`], [`anyNamed`],
 [`argThat`], [`captureThat`], etc.) is passed to a mock method, then the
 [`equals`] matcher is used for argument matching. If you need more strict
-matching consider use `argThat(same(arg))`.
+matching consider use `argThat(identical(arg))`.
 
 However, note that `null` cannot be used as an argument adjacent to ArgMatcher
 arguments, nor as an un-wrapped value passed as a named argument. For example:
diff --git a/mockito/build.yaml b/mockito/build.yaml
index 755c286..3945a14 100644
--- a/mockito/build.yaml
+++ b/mockito/build.yaml
@@ -4,3 +4,4 @@
     builder_factories: ["buildMocks"]
     build_extensions: {".dart": [".mocks.dart"]}
     build_to: source
+    auto_apply: dependents
diff --git a/mockito/lib/src/builder.dart b/mockito/lib/src/builder.dart
index a0fcf4c8c..32fc274 100644
--- a/mockito/lib/src/builder.dart
+++ b/mockito/lib/src/builder.dart
@@ -40,6 +40,7 @@
 class MockBuilder implements Builder {
   @override
   Future<void> build(BuildStep buildStep) async {
+    if (!await buildStep.resolver.isLibrary(buildStep.inputId)) return;
     final entryLib = await buildStep.inputLibrary;
     if (entryLib == null) return;
     final sourceLibIsNonNullable = entryLib.isNonNullableByDefault;
@@ -207,6 +208,9 @@
             '$joinedMessages');
       }
       return typeToMock as analyzer.InterfaceType;
+    } else if (elementToMock is FunctionTypeAliasElement) {
+      throw InvalidMockitoAnnotationException('Mockito cannot mock a typedef: '
+          '${elementToMock.displayName}');
     } else if (elementToMock is GenericFunctionTypeElement &&
         elementToMock.enclosingElement is FunctionTypeAliasElement) {
       throw InvalidMockitoAnnotationException('Mockito cannot mock a typedef: '
@@ -956,7 +960,13 @@
         });
       }
       return TypeReference((b) {
-        var typedef = element.enclosingElement;
+        Element typedef;
+        if (element is FunctionTypeAliasElement) {
+          typedef = element;
+        } else {
+          typedef = element.enclosingElement;
+        }
+
         b
           ..symbol = typedef.name
           ..url = _typeImport(type)
diff --git a/mockito/lib/src/mock.dart b/mockito/lib/src/mock.dart
index e2d4166..24d2fba 100644
--- a/mockito/lib/src/mock.dart
+++ b/mockito/lib/src/mock.dart
@@ -47,9 +47,13 @@
 /// Opt-into [Mock] throwing [NoSuchMethodError] for unimplemented methods.
 ///
 /// The default behavior when not using this is to always return `null`.
-void throwOnMissingStub(Mock mock) {
+void throwOnMissingStub(
+  Mock mock, {
+  void Function(Invocation) exceptionBuilder,
+}) {
+  exceptionBuilder ??= mock._noSuchMethod;
   mock._defaultResponse =
-      () => CallPair<dynamic>.allInvocations(mock._noSuchMethod);
+      () => CallPair<dynamic>.allInvocations(exceptionBuilder);
 }
 
 /// Extend or mixin this class to mark the implementation as a [Mock].
diff --git a/mockito/pubspec.yaml b/mockito/pubspec.yaml
index 75c991e..e9e4aa6 100644
--- a/mockito/pubspec.yaml
+++ b/mockito/pubspec.yaml
@@ -1,5 +1,5 @@
 name: mockito
-version: 4.1.2
+version: 4.1.3
 
 description: A mock framework inspired by Mockito.
 homepage: https://github.com/dart-lang/mockito
@@ -8,7 +8,7 @@
   sdk: '>=2.7.0 <3.0.0'
 
 dependencies:
-  analyzer: ^0.39.15
+  analyzer: '>=0.39.15 <0.41.0'
   build: ^1.3.0
   code_builder: ^3.4.0
   collection: ^1.1.0
@@ -23,5 +23,5 @@
   build_test: ^1.1.0
   build_web_compilers: '>=1.0.0 <3.0.0'
   package_config: ^1.9.3
-  pedantic: 1.10.0-nullsafety
+  pedantic: ^1.10.0-nullsafety
   test: ^1.5.1