Ben Konyi 1709c884aa
[ Tool ] Enable omit_obvious_*_types and specify_nonobvious_*_types lints (#172018)
Sources under `packages/flutter_tools/` aren't accessible to the average
Flutter user by navigating through sources from their projects, so it
doesn't need to be as explicitly verbose with types for readability
purposes. The `always_specify_types` lint results in extremely verbose
code within the tool which adds little value.

This change disables `always_specify_types` in favor of a new set of
lints that aim to reduce verbosity by removing obvious types while also
maintaining readability in cases where variable types otherwise wouldn't
be obvious:

  - `omit_obvious_local_variable_types`
  - `omit_obvious_property_types`
  - `specify_nonobvious_local_variable_types`
  - `specify_nonobvious_property_types`
2025-07-11 19:32:57 +00:00

89 lines
2.9 KiB
Dart

// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@Tags(<String>['flutter-test-driver'])
library;
import 'dart:async';
import 'package:file/file.dart';
import '../src/common.dart';
import 'test_data/background_project.dart';
import 'test_driver.dart';
import 'test_utils.dart';
void main() {
late Directory tempDir;
setUp(() async {
tempDir = createResolvedTempDirectorySync('hot_reload_test.');
});
tearDown(() async {
tryToDelete(tempDir);
});
testWithoutContext('Hot restart kills background isolates', () async {
final project = BackgroundProject();
await project.setUpIn(tempDir);
final flutter = FlutterRunTestDriver(tempDir);
const newBackgroundMessage = 'New Background';
final sawForegroundMessage = Completer<void>.sync();
final sawBackgroundMessage = Completer<void>.sync();
final sawNewBackgroundMessage = Completer<void>.sync();
final StreamSubscription<String> subscription = flutter.stdout.listen((String line) {
printOnFailure('[LOG]:"$line"');
if (line.contains('Main thread') && !sawForegroundMessage.isCompleted) {
sawForegroundMessage.complete();
}
if (line.contains('Isolate thread')) {
sawBackgroundMessage.complete();
}
if (line.contains(newBackgroundMessage)) {
sawNewBackgroundMessage.complete();
}
});
await flutter.run();
await sawForegroundMessage.future;
await sawBackgroundMessage.future;
project.updateTestIsolatePhrase(newBackgroundMessage);
await flutter.hotRestart();
await sawNewBackgroundMessage.future;
// Wait a tiny amount of time in case we did not kill the background isolate.
await Future<void>.delayed(const Duration(milliseconds: 10));
await subscription.cancel();
await flutter.stop();
});
testWithoutContext('Hot reload updates background isolates', () async {
final project = RepeatingBackgroundProject();
await project.setUpIn(tempDir);
final flutter = FlutterRunTestDriver(tempDir);
const newBackgroundMessage = 'New Background';
final sawBackgroundMessage = Completer<void>.sync();
final sawNewBackgroundMessage = Completer<void>.sync();
final StreamSubscription<String> subscription = flutter.stdout.listen((String line) {
printOnFailure('[LOG]:"$line"');
if (line.contains('Isolate thread') && !sawBackgroundMessage.isCompleted) {
sawBackgroundMessage.complete();
}
if (line.contains(newBackgroundMessage) && !sawNewBackgroundMessage.isCompleted) {
sawNewBackgroundMessage.complete();
}
});
await flutter.run();
await sawBackgroundMessage.future;
project.updateTestIsolatePhrase(newBackgroundMessage);
await flutter.hotReload();
await sawNewBackgroundMessage.future;
await subscription.cancel();
await flutter.stop();
});
}