Repository: flutter
Issue: [Flutter 3.10] analyzer shows undefined name errors for `flutter_test` matchers
Labels: a: tests,c: crash,framework,P2,found in release: 3.10,team-framework,triaged-framework

### Is there an existing issue for this?

- [X] I have searched the [existing issues](https://github.com/flutter/flutter/issues)
- [X] I have read the [guide to filing a bug](https://flutter.dev/docs/resources/bug-reports)

### Steps to reproduce

Import `flutter_test` and write any unit test with `expect()` method. If you use matchers `equals()`, `completes`, `isA()`, `throwsA()`, `predicate()` or class `TypeMatcher` analyzer will show error like that: 
```
error: The function 'equals' isn't defined.
error: The name 'TypeMatcher' isn't a class.
error: Undefined name 'completes'.
```

And I cannot find any documentation what has changed on `flutter_test` and how to resolve occurring errors.

### Expected results

Working tests.

### Actual results

Analyzer underlines errors

### Code sample

<details><summary>Code sample</summary>

```dart
import 'dart:convert';

import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:skills/src/authorization/application/local_auth_service.dart';
import 'package:skills/src/authorization/domain/token_model.dart';
import 'package:skills/src/globals/application/init_storages.dart';

import '../../test_resources/test_constants.dart';
import 'local_auth_service_unit_test.mocks.dart';

class MockStorages extends Storages {
  MockStorages(this.prefs, this.secureStr);

  final SharedPreferences prefs;
  final FlutterSecureStorage secureStr;

  @override
  Future<void> init() async {
    sharedPreferences = prefs;
    secureStorage = secureStr;
  }
}

@GenerateMocks(<Type>[FlutterSecureStorage])
Future<void> main() async {
  TestWidgetsFlutterBinding.ensureInitialized();

  late LocalAuthorizationService localService;
  late MockStorages storages;
  SharedPreferences.setMockInitialValues(<String, Object>{});
  final SharedPreferences prefs = await SharedPreferences.getInstance();
  late MockFlutterSecureStorage secureStr;

  late ProviderContainer container;

  setUp(() async {
    secureStr = MockFlutterSecureStorage();
    storages = MockStorages(prefs, secureStr);
    await storages.init();
    container = ProviderContainer(
      overrides: <Override>[storagesProvider.overrideWithValue(storages)],
    );
    localService = LocalAuthorizationService(container.read(storagesProvider));
  });

  group('Local authorization service', () {
    test('Save token', () {
      when(
        secureStr.write(
          key: localService.tokenKey,
          value: json.encode(tToken),
        ),
      ).thenAnswer((final Invocation invocation) => Future<void>.value());

      localService.saveToken(tToken);

      final String expectedJsonString = json.encode(tToken.toJson());

      verify(
        secureStr.write(
          key: localService.tokenKey,
          value: expectedJsonString,
        ),
      );
    });

    test('Get token', () async {
      final String expectedJsonString = json.encode(tToken.toJson());

      when(
        secureStr.read(
          key: localService.tokenKey,
        ),
      ).thenAnswer((final Invocation invocation) async => expectedJsonString);

      final JwtToken? result = await localService.getToken();

      verify(secureStr.read(key: localService.tokenKey));
      expect(result, equals(tToken));
    });

    test('Get token when no token was saved', () async {
      when(
        secureStr.read(
          key: localService.tokenKey,
        ),
      ).thenAnswer((final Invocation invocation) async => null);

      final JwtToken? result = await localService.getToken();

      verify(secureStr.read(key: localService.tokenKey));
      expect(result, null);
    });

    test('Delete token', () {
      when(
        secureStr.write(
          key: localService.tokenKey,
          value: json.encode(tToken),
        ),
      ).thenAnswer((final Invocation invocation) => Future<void>.value());

      localService.saveToken(tToken);

      final String expectedJsonString = json.encode(tToken.toJson());

      verify(
        secureStr.write(
          key: localService.tokenKey,
          value: expectedJsonString,
        ),
      );

      when(
        secureStr.delete(key: localService.tokenKey),
      ).thenAnswer((final Invocation invocation) => Future<void>.value());

      localService.dropToken();

      verify(
        secureStr.delete(
          key: localService.tokenKey,
        ),
      );
    });

    test('Set variable isFirstEnter', () {
      localService.setIsFirstEnter(isFirst: false);
      final bool? result = prefs.getBool(localService.firstEnter);
      expect(result, false);
    });

    test('Get variable isFirstEnter', () async {
      await localService.getIsFirstEnter();
      expect(await localService.getIsFirstEnter(), false);
    });

    test('Get variable isFirstEnter, when it was not passed', () async {
      await prefs.clear();
      await localService.getIsFirstEnter();
      expect(await localService.getIsFirstEnter(), true);
    });

    test('Set variable isBiometryEnabled', () {
      localService.setIsBiometryEnabled(isBiometryEnabled: true);
      final bool? result = prefs.getBool(localService.biometryEnabled);
      expect(result, true);
    });

    test('Get variable isBiometryEnabled', () async {
      await localService.getIsBiometryEnabled();
      expect(await localService.getIsBiometryEnabled(), true);
    });

    test('Get variable isBiometryEnabled, when it was not passed', () async {
      await prefs.clear();
      await localService.getIsBiometryEnabled();
      expect(await localService.getIsBiometryEnabled(), false);
    });

    test('Save credentials', () async {
      when(
        secureStr.write(
          key: localService.loginKey,
          value: json.encode(tToken),
        ),
      ).thenAnswer((final Invocation invocation) => Future<void>.value());

      when(
        secureStr.write(
          key: localService.passwordKey,
          value: json.encode(tToken),
        ),
      ).thenAnswer((final Invocation invocation) => Future<void>.value());

      await localService.saveCredentials(tLogin, tPassword);

      verifyInOrder(
        <Future<void>>[
          secureStr.write(key: localService.loginKey, value: tLogin),
          secureStr.write(key: localService.passwordKey, value: tPassword),
        ],
      );
    });

    test('Get login', () async {
      when(
        secureStr.read(
          key: localService.loginKey,
        ),
      ).thenAnswer((final Invocation invocation) async => tLogin);

      final String? result = await localService.getLogin();

      verify(secureStr.read(key: localService.loginKey));
      expect(result, equals(tLogin));
    });

    test('Get password', () async {
      when(
        secureStr.read(
          key: localService.passwordKey,
        ),
      ).thenAnswer((final Invocation invocation) async => tPassword);

      final String? result = await localService.getPassword();

      verify(secureStr.read(key: localService.passwordKey));
      expect(result, equals(tPassword));
    });
  });
}
```

</details>


### Screenshots or Video

<details>
<summary>Screenshots / Video demonstration</summary>

![Снимок экрана 2023-05-25 в 08 27 43](https://github.com/flutter/flutter/assets/82471392/f28c8f8a-09de-422b-9830-f7875f2ecd13)

</details>


### Logs

<details><summary>Logs</summary>

```console
[Paste your logs here]
```

</details>


### Flutter Doctor output

<details><summary>Doctor output</summary>

```console
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.10.1, on macOS 13.3.1 22E261 darwin-arm64, locale ru-RU)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.1)
[✓] IntelliJ IDEA Ultimate Edition (version 2023.1.1)
[✓] IntelliJ IDEA Community Edition (version 2022.2)
[✓] VS Code (version 1.78.0)
[✓] Connected device (3 available)
[✓] Network resources

• No issues found!
```

</details>