@@ -74,7 +74,7 @@ class MockBuilder implements Builder {
74
74
Future <void > build (BuildStep buildStep) async {
75
75
if (! await buildStep.resolver.isLibrary (buildStep.inputId)) return ;
76
76
final entryLib = await buildStep.inputLibrary;
77
- final sourceLibIsNonNullable = entryLib.isNonNullableByDefault ;
77
+ final sourceLibIsNonNullable = true ;
78
78
79
79
final mockLibraryAsset = buildStep.allowedOutputs.singleOrNull;
80
80
if (mockLibraryAsset == null ) {
@@ -144,13 +144,11 @@ class MockBuilder implements Builder {
144
144
// The source lib may be pre-null-safety because of an explicit opt-out
145
145
// (`// @dart=2.9`), as opposed to living in a pre-null-safety package. To
146
146
// allow for this situation, we must also add an opt-out comment here.
147
- final dartVersionComment = sourceLibIsNonNullable ? '' : '// @dart=2.9' ;
148
147
final mockLibraryContent = DartFormatter ().format ('''
149
148
// Mocks generated by Mockito $packageVersion from annotations
150
149
// in ${entryLib .definingCompilationUnit .source .uri .path }.
151
150
// Do not manually edit this file.
152
151
153
- $dartVersionComment
154
152
155
153
$rawOutput
156
154
''' );
@@ -1051,7 +1049,7 @@ class _MockLibraryInfo {
1051
1049
final fallbackGenerators = mockTarget.fallbackGenerators;
1052
1050
mockClasses.add (_MockClassInfo (
1053
1051
mockTarget: mockTarget,
1054
- sourceLibIsNonNullable: entryLib.isNonNullableByDefault ,
1052
+ sourceLibIsNonNullable: true ,
1055
1053
typeProvider: entryLib.typeProvider,
1056
1054
typeSystem: entryLib.typeSystem,
1057
1055
mockLibraryInfo: this ,
@@ -1175,9 +1173,8 @@ class _MockClassInfo {
1175
1173
// The test can be pre-null-safety but if the class
1176
1174
// we want to mock is defined in a null safe library,
1177
1175
// we still need to override methods to get nice mocks.
1178
- final isNiceMockOfNullSafeClass = mockTarget.onMissingStub ==
1179
- OnMissingStub .returnDefault &&
1180
- typeToMock.element.enclosingElement.library.isNonNullableByDefault;
1176
+ final isNiceMockOfNullSafeClass =
1177
+ mockTarget.onMissingStub == OnMissingStub .returnDefault;
1181
1178
1182
1179
if (sourceLibIsNonNullable || isNiceMockOfNullSafeClass) {
1183
1180
cBuilder.methods.addAll (
0 commit comments