diff --git a/lib/web_ui/analysis_options.yaml b/lib/web_ui/analysis_options.yaml index 4a275217a6cf1..32c57e6952827 100644 --- a/lib/web_ui/analysis_options.yaml +++ b/lib/web_ui/analysis_options.yaml @@ -13,7 +13,6 @@ analyzer: linter: rules: - always_specify_types: false annotate_overrides: false avoid_classes_with_only_static_members: false avoid_empty_else: false diff --git a/lib/web_ui/dev/browser.dart b/lib/web_ui/dev/browser.dart index a3d222be9be3a..d2fdd7b26d0a1 100644 --- a/lib/web_ui/dev/browser.dart +++ b/lib/web_ui/dev/browser.dart @@ -76,20 +76,20 @@ abstract class Browser { /// /// This will fire once the process has started successfully. Future get _process => _processCompleter.future; - final _processCompleter = Completer(); + final Completer _processCompleter = Completer(); /// Whether [close] has been called. - var _closed = false; + bool _closed = false; /// A future that completes when the browser exits. /// /// If there's a problem starting or running the browser, this will complete /// with an error. Future get onExit => _onExitCompleter.future; - final _onExitCompleter = Completer(); + final Completer _onExitCompleter = Completer(); /// Standard IO streams for the underlying browser process. - final _ioSubscriptions = []; + final List> _ioSubscriptions = >[]; /// Creates a new browser. /// @@ -102,10 +102,10 @@ abstract class Browser { // for the process to actually start. They should just wait for the HTTP // request instead. runZonedGuarded(() async { - var process = await startBrowser(); + Process process = await startBrowser(); _processCompleter.complete(process); - var output = Uint8Buffer(); + Uint8Buffer output = Uint8Buffer(); void drainOutput(Stream> stream) { try { _ioSubscriptions @@ -117,7 +117,7 @@ abstract class Browser { drainOutput(process.stdout); drainOutput(process.stderr); - var exitCode = await process.exitCode; + int exitCode = await process.exitCode; // This hack dodges an otherwise intractable race condition. When the user // presses Control-C, the signal is sent to the browser and the test @@ -134,8 +134,8 @@ abstract class Browser { } if (!_closed && exitCode != 0) { - var outputString = utf8.decode(output); - var message = '$name failed with exit code $exitCode.'; + String outputString = utf8.decode(output); + String message = '$name failed with exit code $exitCode.'; if (outputString.isNotEmpty) { message += '\nStandard output:\n$outputString'; } @@ -151,7 +151,7 @@ abstract class Browser { } // Make sure the process dies even if the error wasn't fatal. - _process.then((process) => process.kill()); + _process.then((Process process) => process.kill()); if (stackTrace == null) { stackTrace = Trace.current(); @@ -170,13 +170,13 @@ abstract class Browser { /// /// Returns the same [Future] as [onExit], except that it won't emit /// exceptions. - Future close() async { + Future close() async { _closed = true; // If we don't manually close the stream the test runner can hang. // For example this happens with Chrome Headless. // See SDK issue: https://github.com/dart-lang/sdk/issues/31264 - for (var stream in _ioSubscriptions) { + for (StreamSubscription stream in _ioSubscriptions) { unawaited(stream.cancel()); } @@ -192,7 +192,7 @@ abstract class ScreenshotManager { /// Capture a screenshot. /// /// Please read the details for the implementing classes. - Future capture(math.Rectangle region); + Future capture(math.Rectangle region); /// Suffix to be added to the end of the filename. /// diff --git a/lib/web_ui/dev/build.dart b/lib/web_ui/dev/build.dart index 039ac62d2d578..dafb3bb7fff8f 100644 --- a/lib/web_ui/dev/build.dart +++ b/lib/web_ui/dev/build.dart @@ -7,12 +7,13 @@ import 'dart:async'; import 'package:args/command_runner.dart'; import 'package:path/path.dart' as path; +import 'package:watcher/src/watch_event.dart'; import 'environment.dart'; import 'utils.dart'; import 'watcher.dart'; -class BuildCommand extends Command with ArgUtils { +class BuildCommand extends Command with ArgUtils { BuildCommand() { argParser ..addFlag( @@ -48,7 +49,7 @@ class BuildCommand extends Command with ArgUtils { dir: libPath.absolute, pipeline: buildPipeline, // Ignore font files that are copied whenever tests run. - ignore: (event) => event.path.endsWith('.ttf'), + ignore: (WatchEvent event) => event.path.endsWith('.ttf'), ).start(); } return true; diff --git a/lib/web_ui/dev/chrome.dart b/lib/web_ui/dev/chrome.dart index af0c671bb245e..3f9cbab58bc02 100644 --- a/lib/web_ui/dev/chrome.dart +++ b/lib/web_ui/dev/chrome.dart @@ -51,7 +51,7 @@ class ChromeEnvironment implements BrowserEnvironment { /// Any errors starting or running the process are reported through [onExit]. class Chrome extends Browser { @override - final name = 'Chrome'; + final String name = 'Chrome'; @override final Future remoteDebuggerUrl; @@ -60,7 +60,7 @@ class Chrome extends Browser { /// [Uri] or a [String]. factory Chrome(Uri url, {bool debug = false}) { String version = ChromeArgParser.instance.version; - var remoteDebuggerCompleter = Completer.sync(); + Completer remoteDebuggerCompleter = Completer.sync(); return Chrome._(() async { final BrowserInstallation installation = await getOrInstallChrome( version, @@ -80,7 +80,7 @@ class Chrome extends Browser { final bool isChromeNoSandbox = Platform.environment['CHROME_NO_SANDBOX'] == 'true'; final String dir = environment.webUiDartToolDir.createTempSync('test_chrome_user_data_').resolveSymbolicLinksSync(); - var args = [ + List args = [ '--user-data-dir=$dir', url.toString(), if (!debug) @@ -218,7 +218,7 @@ class ChromeScreenshotManager extends ScreenshotManager { /// [region] is used to decide which part of the web content will be used in /// test image. It includes starting coordinate x,y as well as height and /// width of the area to capture. - Future capture(math.Rectangle? region) async { + Future capture(math.Rectangle? region) async { final wip.ChromeConnection chromeConnection = wip.ChromeConnection('localhost', kDevtoolsPort); final wip.ChromeTab? chromeTab = await chromeConnection.getTab( diff --git a/lib/web_ui/dev/chrome_installer.dart b/lib/web_ui/dev/chrome_installer.dart index d84e2c1c1154d..bdbd43a25c8bf 100644 --- a/lib/web_ui/dev/chrome_installer.dart +++ b/lib/web_ui/dev/chrome_installer.dart @@ -4,6 +4,7 @@ import 'dart:async'; import 'dart:io' as io; +import 'dart:typed_data'; import 'package:archive/archive.dart'; import 'package:archive/archive_io.dart'; @@ -220,7 +221,7 @@ class ChromeInstaller { final Stopwatch stopwatch = Stopwatch()..start(); // Read the Zip file from disk. - final bytes = downloadedFile.readAsBytesSync(); + final Uint8List bytes = downloadedFile.readAsBytesSync(); final Archive archive = ZipDecoder().decodeBytes(bytes); @@ -228,7 +229,7 @@ class ChromeInstaller { for (final ArchiveFile file in archive) { final String filename = file.name; if (file.isFile) { - final data = file.content as List; + final List data = file.content as List; io.File(path.join(versionDir.path, filename)) ..createSync(recursive: true) ..writeAsBytesSync(data); diff --git a/lib/web_ui/dev/clean.dart b/lib/web_ui/dev/clean.dart index a7a00e911ce02..9bc4c99faa072 100644 --- a/lib/web_ui/dev/clean.dart +++ b/lib/web_ui/dev/clean.dart @@ -11,7 +11,7 @@ import 'package:path/path.dart' as path; import 'environment.dart'; import 'utils.dart'; -class CleanCommand extends Command with ArgUtils { +class CleanCommand extends Command with ArgUtils { CleanCommand() { argParser ..addFlag( diff --git a/lib/web_ui/dev/common.dart b/lib/web_ui/dev/common.dart index 97a6e3a79f984..7617d526c38b1 100644 --- a/lib/web_ui/dev/common.dart +++ b/lib/web_ui/dev/common.dart @@ -221,7 +221,7 @@ class DevNull implements StringSink { void write(Object? obj) {} @override - void writeAll(Iterable objects, [String separator = ""]) {} + void writeAll(Iterable objects, [String separator = ""]) {} @override void writeCharCode(int charCode) {} diff --git a/lib/web_ui/dev/create_simulator.dart b/lib/web_ui/dev/create_simulator.dart index c325aff7dabe4..b35b41ac2c9fe 100644 --- a/lib/web_ui/dev/create_simulator.dart +++ b/lib/web_ui/dev/create_simulator.dart @@ -10,7 +10,7 @@ import 'package:simulators/simulator_manager.dart'; import 'safari_installation.dart'; import 'utils.dart'; -class CreateSimulatorCommand extends Command with ArgUtils { +class CreateSimulatorCommand extends Command with ArgUtils { CreateSimulatorCommand() { IosSafariArgParser.instance.populateOptions(argParser); argParser diff --git a/lib/web_ui/dev/edge.dart b/lib/web_ui/dev/edge.dart index a1294a3bc6e03..a2a0b0aeb00bd 100644 --- a/lib/web_ui/dev/edge.dart +++ b/lib/web_ui/dev/edge.dart @@ -42,7 +42,7 @@ class EdgeEnvironment implements BrowserEnvironment { /// Any errors starting or running the process are reported through [onExit]. class Edge extends Browser { @override - final name = 'Edge'; + final String name = 'Edge'; /// Starts a new instance of Safari open to the given [url], which may be a /// [Uri] or a [String]. @@ -63,8 +63,10 @@ class Edge extends Browser { pathToOpen = pathToOpen.substring(0, index-1); } - var process = - await Process.start(installation.executable, ['$pathToOpen','-k']); + Process process = await Process.start( + installation.executable, + ['$pathToOpen','-k'], + ); return process; }); diff --git a/lib/web_ui/dev/felt.dart b/lib/web_ui/dev/felt.dart index f99c0ac3be8c3..cd59ec1bac15a 100644 --- a/lib/web_ui/dev/felt.dart +++ b/lib/web_ui/dev/felt.dart @@ -14,7 +14,7 @@ import 'exceptions.dart'; import 'test_runner.dart'; import 'utils.dart'; -CommandRunner runner = CommandRunner( +CommandRunner runner = CommandRunner( 'felt', 'Command-line utility for building and testing Flutter web engine.', ) @@ -26,7 +26,7 @@ CommandRunner runner = CommandRunner( void main(List rawArgs) async { // Remove --clean from the list as that's processed by the wrapper script. - final List args = rawArgs.where((arg) => arg != '--clean').toList(); + final List args = rawArgs.where((String arg) => arg != '--clean').toList(); if (args.isEmpty) { // The felt tool was invoked with no arguments. Print usage. diff --git a/lib/web_ui/dev/firefox.dart b/lib/web_ui/dev/firefox.dart index 405e4378f2770..5cc8d7b9f0502 100644 --- a/lib/web_ui/dev/firefox.dart +++ b/lib/web_ui/dev/firefox.dart @@ -47,7 +47,7 @@ class FirefoxEnvironment implements BrowserEnvironment { /// Any errors starting or running the process are reported through [onExit]. class Firefox extends Browser { @override - final name = 'Firefox'; + final String name = 'Firefox'; @override final Future remoteDebuggerUrl; @@ -56,7 +56,7 @@ class Firefox extends Browser { /// [Uri] or a [String]. factory Firefox(Uri url, {bool debug = false}) { final String version = FirefoxArgParser.instance.version; - var remoteDebuggerCompleter = Completer.sync(); + Completer remoteDebuggerCompleter = Completer.sync(); return Firefox._(() async { final BrowserInstallation installation = await getOrInstallFirefox( version, @@ -64,7 +64,7 @@ class Firefox extends Browser { ); // Using a profile on opening will prevent popups related to profiles. - final _profile = ''' + final String _profile = ''' user_pref("browser.shell.checkDefaultBrowser", false); user_pref("dom.disable_open_during_load", false); user_pref("dom.max_script_run_time", 0); @@ -84,7 +84,7 @@ user_pref("dom.max_script_run_time", 0); File(path.join(temporaryProfileDirectory.path, 'prefs.js')) .writeAsStringSync(_profile); bool isMac = Platform.isMacOS; - var args = [ + List args = [ url.toString(), '--profile', '${temporaryProfileDirectory.path}', diff --git a/lib/web_ui/dev/firefox_installer.dart b/lib/web_ui/dev/firefox_installer.dart index 09895f3bcad72..fe4e2f4282a9e 100644 --- a/lib/web_ui/dev/firefox_installer.dart +++ b/lib/web_ui/dev/firefox_installer.dart @@ -308,7 +308,7 @@ Future _findSystemFirefoxExecutable() async { if (!found) { if (io.Platform.isMacOS && io.File(fireFoxDefaultInstallPath).existsSync()) { - return Future.value(fireFoxDefaultInstallPath); + return Future.value(fireFoxDefaultInstallPath); } throw BrowserInstallerException( 'Failed to locate system Firefox installation.'); diff --git a/lib/web_ui/dev/licenses.dart b/lib/web_ui/dev/licenses.dart index ea3b2233e1f0e..5e56a073c27be 100644 --- a/lib/web_ui/dev/licenses.dart +++ b/lib/web_ui/dev/licenses.dart @@ -29,7 +29,7 @@ class LicensesCommand extends Command { 'Dart source listing of ${environment.webUiRootDir.path} must not be empty.'); final List allDartPaths = - allSourceFiles.map((f) => f.path).toList(); + allSourceFiles.map((io.File f) => f.path).toList(); for (String expectedDirectory in const [ 'lib', @@ -41,7 +41,7 @@ class LicensesCommand extends Command { path.join(environment.webUiRootDir.path, expectedDirectory); _expect( allDartPaths - .where((p) => p.startsWith(expectedAbsoluteDirectory)) + .where((String p) => p.startsWith(expectedAbsoluteDirectory)) .isNotEmpty, 'Must include the $expectedDirectory/ directory', ); @@ -51,7 +51,7 @@ class LicensesCommand extends Command { print('License headers OK!'); } - final _copyRegex = + final RegExp _copyRegex = RegExp(r'// Copyright 2013 The Flutter Authors\. All rights reserved\.'); void _expectLicenseHeader(io.File file) { @@ -80,7 +80,7 @@ class LicensesCommand extends Command { } List _flatListSourceFiles(io.Directory directory) { - return directory.listSync(recursive: true).whereType().where((f) { + return directory.listSync(recursive: true).whereType().where((io.File f) { if (!f.path.endsWith('.dart') && !f.path.endsWith('.js')) { // Not a source file we're checking. return false; diff --git a/lib/web_ui/dev/macos_info.dart b/lib/web_ui/dev/macos_info.dart index 33ab087a868fc..fba317ac6517a 100644 --- a/lib/web_ui/dev/macos_info.dart +++ b/lib/web_ui/dev/macos_info.dart @@ -21,7 +21,7 @@ class MacOSInfo { Future _printSafariApplications() async { final ProcessManager systemProfiler = await startProcess( 'system_profiler', - ['SPApplicationsDataType', '-json'], + ['SPApplicationsDataType', '-json'], evalOutput: true, ); final String systemProfileJson = await systemProfiler.evalStdout(); @@ -44,7 +44,7 @@ class MacOSInfo { Future _printSafariDefaults() async { final ProcessManager defaults = await startProcess( '/usr/bin/defaults', - ['find', 'Safari'], + ['find', 'Safari'], evalOutput: true, ); print('Safari related defaults:\n ${await defaults.evalStdout()}'); @@ -52,11 +52,11 @@ class MacOSInfo { /// Print user limits (file and process). Future _printUserLimits() async { - ProcessManager ulimit = await startProcess('ulimit', ['-n'], evalOutput: true); + ProcessManager ulimit = await startProcess('ulimit', ['-n'], evalOutput: true); final String fileLimit = await ulimit.evalStdout(); print('MacOS file limit: $fileLimit'); - ulimit = await startProcess('ulimit', ['-u'], evalOutput: true); + ulimit = await startProcess('ulimit', ['-u'], evalOutput: true); final String processLimit = await ulimit.evalStdout(); print('MacOS process limit: $processLimit'); } diff --git a/lib/web_ui/dev/safari_installation.dart b/lib/web_ui/dev/safari_installation.dart index df69c566f1d42..cdc99e5dc5015 100644 --- a/lib/web_ui/dev/safari_installation.dart +++ b/lib/web_ui/dev/safari_installation.dart @@ -138,7 +138,7 @@ class IosSafariArgParser extends BrowserArgParser { @override void populateOptions(ArgParser argParser) { - final pinnedIosVersion = + final String pinnedIosVersion = '${_pinnedIosMajorVersion}.${_pinnedIosMinorVersion}'; argParser ..addOption('version', diff --git a/lib/web_ui/dev/safari_ios.dart b/lib/web_ui/dev/safari_ios.dart index f12936c1c654a..d673c54c600a5 100644 --- a/lib/web_ui/dev/safari_ios.dart +++ b/lib/web_ui/dev/safari_ios.dart @@ -51,7 +51,7 @@ class SafariIosEnvironment implements BrowserEnvironment { /// Any errors starting or running the process are reported through [onExit]. class SafariIos extends Browser { @override - final name = 'Safari iOS'; + final String name = 'Safari iOS'; /// Starts a new instance of Safari open to the given [url], which may be a /// [Uri]. @@ -61,7 +61,7 @@ class SafariIos extends Browser { // Uses `xcrun simctl`. It is a command line utility to control the // Simulator. For more details on interacting with the simulator: // https://developer.apple.com/library/archive/documentation/IDEs/Conceptual/iOS_Simulator_Guide/InteractingwiththeiOSSimulator/InteractingwiththeiOSSimulator.html - var process = await io.Process.start('xcrun', [ + io.Process process = await io.Process.start('xcrun', [ 'simctl', 'openurl', // Opens the url on Safari installed on the simulator. 'booted', // The simulator is already booted. @@ -154,7 +154,7 @@ class SafariIosScreenshotManager extends ScreenshotManager { /// width of the area to capture. /// /// Uses simulator tool `xcrun simctl`'s 'screenshot' command. - Future capture(math.Rectangle? region) async { + Future capture(math.Rectangle? region) async { final String filename = 'screenshot${_fileNameCounter}.png'; _fileNameCounter++; @@ -186,7 +186,7 @@ class SafariIosScreenshotManager extends ScreenshotManager { if (region == null) { return content; } else { - final math.Rectangle scaledRegion = _scaleScreenshotRegion(region); + final math.Rectangle scaledRegion = _scaleScreenshotRegion(region); return copyCrop( content, scaledRegion.left.toInt(), @@ -200,8 +200,8 @@ class SafariIosScreenshotManager extends ScreenshotManager { /// Perform a linear transform on the screenshot region to convert its /// dimensions from linear coordinated to coordinated on the phone screen. /// This uniform/isotropic scaling is done using [_scaleFactor]. - math.Rectangle _scaleScreenshotRegion(math.Rectangle region) { - return math.Rectangle( + math.Rectangle _scaleScreenshotRegion(math.Rectangle region) { + return math.Rectangle( region.left * _scaleFactor, region.top * _scaleFactor, region.width * _scaleFactor, diff --git a/lib/web_ui/dev/safari_macos.dart b/lib/web_ui/dev/safari_macos.dart index 7579155789b3c..d1ec20b27b913 100644 --- a/lib/web_ui/dev/safari_macos.dart +++ b/lib/web_ui/dev/safari_macos.dart @@ -43,7 +43,7 @@ class SafariMacOsEnvironment implements BrowserEnvironment { /// Any errors starting or running the process are reported through [onExit]. class SafariMacOs extends Browser { @override - final name = 'Safari macOS'; + final String name = 'Safari macOS'; /// Starts a new instance of Safari open to the given [url], which may be a /// [Uri]. @@ -64,7 +64,7 @@ class SafariMacOs extends Browser { // persistent state and wait until it opens. // The details copied from `man open` on macOS. // TODO(nurhan): https://github.com/flutter/flutter/issues/50809 - var process = await Process.start(installation.executable, [ + Process process = await Process.start(installation.executable, [ // These are flags for `open` command line tool. '-F', // Open a fresh Safari with no persistent state. '-W', // Wait until the Safari opens. diff --git a/lib/web_ui/dev/test_platform.dart b/lib/web_ui/dev/test_platform.dart index 25da62e32862a..08ae1d538257a 100644 --- a/lib/web_ui/dev/test_platform.dart +++ b/lib/web_ui/dev/test_platform.dart @@ -250,7 +250,7 @@ class BrowserPlatform extends PlatformPlugin { final Map region = requestData['region'] as Map; final PixelComparison pixelComparison = PixelComparison.values.firstWhere( - (value) => value.toString() == requestData['pixelComparison']); + (PixelComparison value) => value.toString() == requestData['pixelComparison']); final String result = await _diffScreenshot( filename, write, maxDiffRate, region, pixelComparison); return shelf.Response.ok(json.encode(result)); @@ -285,7 +285,7 @@ class BrowserPlatform extends PlatformPlugin { ); } - final Rectangle regionAsRectange = Rectangle( + final Rectangle regionAsRectange = Rectangle( region['x'] as num, region['y'] as num, region['width'] as num, @@ -325,7 +325,7 @@ class BrowserPlatform extends PlatformPlugin { - ''', headers: {'Content-Type': 'text/html'}); + ''', headers: {'Content-Type': 'text/html'}); } return shelf.Response.notFound('Not found.'); @@ -371,7 +371,7 @@ class BrowserPlatform extends PlatformPlugin { return suite; } - StreamChannel loadChannel(String path, SuitePlatform platform) => + StreamChannel loadChannel(String path, SuitePlatform platform) => throw UnimplementedError(); Future? _browserManager; @@ -448,10 +448,10 @@ class BrowserPlatform extends PlatformPlugin { /// invalid and don't need to have a persistent URL. class OneOffHandler { /// A map from URL paths to handlers. - final _handlers = Map(); + final Map _handlers = Map(); /// The counter of handlers that have been activated. - var _counter = 0; + int _counter = 0; /// The actual [shelf.Handler] that dispatches requests. shelf.Handler get handler => _onRequest; @@ -463,7 +463,7 @@ class OneOffHandler { /// /// [handler] will be unmounted as soon as it receives a request. String create(shelf.Handler handler) { - var path = _counter.toString(); + String path = _counter.toString(); _handlers[path] = handler; _counter++; return path; @@ -471,13 +471,13 @@ class OneOffHandler { /// Dispatches [request] to the appropriate handler. FutureOr _onRequest(shelf.Request request) { - var components = p.url.split(request.url.path); + List components = p.url.split(request.url.path); if (components.isEmpty) { return shelf.Response.notFound(null); } - var path = components.removeAt(0); - var handler = _handlers.remove(path); + String path = components.removeAt(0); + shelf.Handler? handler = _handlers.remove(path); if (handler == null) { return shelf.Response.notFound(null); } @@ -501,7 +501,7 @@ class BrowserManager { /// The channel used to communicate with the browser. /// /// This is connected to a page running `static/host.dart`. - late final MultiChannel _channel; + late final MultiChannel _channel; /// A pool that ensures that limits the number of initial connections the /// manager will wait for at once. @@ -510,7 +510,7 @@ class BrowserManager { /// loaded in the same browser. However, the browser can only load so many at /// once, and we want a timeout in case they fail so we only wait for so many /// at once. - final _pool = Pool(8); + final Pool _pool = Pool(8); /// The ID of the next suite to be loaded. /// @@ -525,10 +525,10 @@ class BrowserManager { /// /// This will be `null` as long as the browser isn't displaying a pause /// screen. - CancelableCompleter? _pauseCompleter; + CancelableCompleter? _pauseCompleter; /// The controller for [_BrowserEnvironment.onRestart]. - final _onRestartController = StreamController.broadcast(); + final StreamController _onRestartController = StreamController.broadcast(); /// The environment to attach to each suite. late final Future<_BrowserEnvironment> _environment; @@ -537,7 +537,7 @@ class BrowserManager { /// /// These are used to mark suites as debugging or not based on the browser's /// pings. - final _controllers = Set(); + final Set _controllers = Set(); // A timer that's reset whenever we receive a message from the browser. // @@ -563,9 +563,9 @@ class BrowserManager { required PackageConfig packageConfig, bool debug = false, }) { - var browser = _newBrowser(url, browserEnvironment, debug: debug); + Browser browser = _newBrowser(url, browserEnvironment, debug: debug); - var completer = Completer(); + Completer completer = Completer(); // For the cases where we use a delegator such as `adb` (for Android) or // `xcrun` (for IOS), these delegator processes can shut down before the @@ -579,7 +579,7 @@ class BrowserManager { completer.completeError(error, stackTrace); }); - future.then((webSocket) { + future.then((WebSocketChannel webSocket) { if (completer.isCompleted) { return; } @@ -612,7 +612,7 @@ class BrowserManager { // Start this canceled because we don't want it to start ticking until we // get some response from the iframe. _timer = RestartableTimer(Duration(seconds: 3), () { - for (var controller in _controllers) { + for (RunnerSuiteController controller in _controllers) { controller.setDebugging(true); } }) @@ -621,12 +621,12 @@ class BrowserManager { // Whenever we get a message, no matter which child channel it's for, we the // know browser is still running code which means the user isn't debugging. _channel = MultiChannel( - webSocket.cast().transform(jsonDocument).changeStream((stream) { - return stream.map((message) { + webSocket.cast().transform(jsonDocument).changeStream((Stream stream) { + return stream.map((Object? message) { if (!_closed) { _timer.reset(); } - for (var controller in _controllers) { + for (RunnerSuiteController controller in _controllers) { controller.setDebugging(false); } @@ -636,7 +636,7 @@ class BrowserManager { _environment = _loadBrowserEnvironment(); _channel.stream - .listen((dynamic message) => _onMessage(message as Map), onDone: close); + .listen((dynamic message) => _onMessage(message as Map), onDone: close); } /// Loads [_BrowserEnvironment]. @@ -658,28 +658,28 @@ class BrowserManager { 'browser': _browserEnvironment.packageTestRuntime.identifier }))); - var suiteID = _suiteID++; + int suiteID = _suiteID++; RunnerSuiteController? controller; void closeIframe() { if (_closed) { return; } _controllers.remove(controller); - _channel.sink.add({'command': 'closeSuite', 'id': suiteID}); + _channel.sink.add({'command': 'closeSuite', 'id': suiteID}); } // The virtual channel will be closed when the suite is closed, in which // case we should unload the iframe. - var virtualChannel = _channel.virtualChannel(); - var suiteChannelID = virtualChannel.id; - var suiteChannel = virtualChannel.transformStream( - StreamTransformer.fromHandlers(handleDone: (sink) { + VirtualChannel virtualChannel = _channel.virtualChannel(); + int suiteChannelID = virtualChannel.id; + StreamChannel suiteChannel = virtualChannel.transformStream( + StreamTransformer.fromHandlers(handleDone: (EventSink sink) { closeIframe(); sink.close(); })); return _pool.withResource(() async { - _channel.sink.add({ + _channel.sink.add({ 'command': 'loadSuite', 'url': url.toString(), 'id': suiteID, @@ -697,8 +697,8 @@ class BrowserManager { final String mapPath = p.join(env.environment.webUiRootDir.path, 'build', pathToTest, sourceMapFileName); - Map packageMap = { - for (var p in packageConfig.packages) p.name: p.packageUriRoot + Map packageMap = { + for (Package p in packageConfig.packages) p.name: p.packageUriRoot }; final JSStackTraceMapper mapper = JSStackTraceMapper( await File(mapPath).readAsString(), @@ -719,14 +719,14 @@ class BrowserManager { } /// An implementation of [Environment.displayPause]. - CancelableOperation _displayPause() { - CancelableCompleter? pauseCompleter = _pauseCompleter; + CancelableOperation _displayPause() { + CancelableCompleter? pauseCompleter = _pauseCompleter; if (pauseCompleter != null) { return pauseCompleter.operation; } pauseCompleter = CancelableCompleter(onCancel: () { - _channel.sink.add({'command': 'resume'}); + _channel.sink.add({'command': 'resume'}); _pauseCompleter = null; }); _pauseCompleter = pauseCompleter; @@ -735,13 +735,13 @@ class BrowserManager { _pauseCompleter = null; }); - _channel.sink.add({'command': 'displayPause'}); + _channel.sink.add({'command': 'displayPause'}); return pauseCompleter.operation; } /// The callback for handling messages received from the host page. - void _onMessage(Map message) { + void _onMessage(Map message) { switch (message['command'] as String) { case 'ping': break; @@ -763,7 +763,7 @@ class BrowserManager { /// Closes the manager and releases any resources it owns, including closing /// the browser. - Future close() => _closeMemoizer.runOnce(() { + Future close() => _closeMemoizer.runOnce(() { _closed = true; _timer.cancel(); _pauseCompleter?.complete(); @@ -780,18 +780,18 @@ class BrowserManager { class _BrowserEnvironment implements Environment { final BrowserManager _manager; - final supportsDebugging = true; + final bool supportsDebugging = true; final Uri? observatoryUrl; final Uri? remoteDebuggerUrl; - final Stream onRestart; + final Stream onRestart; _BrowserEnvironment(this._manager, this.observatoryUrl, this.remoteDebuggerUrl, this.onRestart); - CancelableOperation displayPause() => _manager._displayPause(); + CancelableOperation displayPause() => _manager._displayPause(); } bool get isCirrus => Platform.environment['CIRRUS_CI'] == 'true'; diff --git a/lib/web_ui/dev/test_runner.dart b/lib/web_ui/dev/test_runner.dart index fb2884bee5767..c2077b24d5367 100644 --- a/lib/web_ui/dev/test_runner.dart +++ b/lib/web_ui/dev/test_runner.dart @@ -26,6 +26,7 @@ import 'package:test_core/src/runner/reporter.dart' import 'package:test_api/src/backend/runtime.dart'; import 'package:test_core/src/executable.dart' as test; +import 'package:watcher/src/watch_event.dart'; import 'package:web_test_utils/goldens.dart'; import 'browser.dart'; @@ -80,7 +81,7 @@ BrowserEnvironment _createBrowserEnvironment(String browserName) { } /// Runs tests. -class TestCommand extends Command with ArgUtils { +class TestCommand extends Command with ArgUtils { TestCommand() { argParser ..addFlag( @@ -201,7 +202,7 @@ class TestCommand extends Command with ArgUtils { await PipelineWatcher( dir: dir.absolute, pipeline: testPipeline, - ignore: (event) { + ignore: (WatchEvent event) { // Ignore font files that are copied whenever tests run. if (event.path.endsWith('.ttf')) { return true; @@ -331,7 +332,7 @@ class TestCommand extends Command with ArgUtils { List get targets => argResults!.rest; /// The target test files to run. - List get targetFiles => targets.map((t) => FilePath.fromCwd(t)).toList(); + List get targetFiles => targets.map((String t) => FilePath.fromCwd(t)).toList(); /// Whether all tests should run. bool get runAllTests => targets.isEmpty; @@ -560,7 +561,7 @@ class TestCommand extends Command with ArgUtils { .map((FilePath f) => TestBuildInput(f, forCanvasKit: forCanvasKit)) .toList(); - final results = _pool.forEach( + final Stream results = _pool.forEach( buildInputs, _buildTest, ); @@ -659,7 +660,7 @@ class TestCommand extends Command with ArgUtils { '--precompiled=${environment.webUiBuildDir.path}', '--configuration=$configurationFilePath', '--', - ...testFiles.map((f) => f.relativeToWebUi).toList(), + ...testFiles.map((FilePath f) => f.relativeToWebUi).toList(), ]; if (expectFailure) { diff --git a/lib/web_ui/lib/src/engine/browser_detection.dart b/lib/web_ui/lib/src/engine/browser_detection.dart index 70e9460c09238..92b6763b453a2 100644 --- a/lib/web_ui/lib/src/engine/browser_detection.dart +++ b/lib/web_ui/lib/src/engine/browser_detection.dart @@ -189,7 +189,7 @@ OperatingSystem detectOperatingSystem({ /// /// These devices tend to behave differently on many core issues such as events, /// screen readers, input devices. -const Set _desktopOperatingSystems = { +const Set _desktopOperatingSystems = { OperatingSystem.macOs, OperatingSystem.linux, OperatingSystem.windows, diff --git a/lib/web_ui/lib/src/engine/canvas_pool.dart b/lib/web_ui/lib/src/engine/canvas_pool.dart index 02d786ea6e0eb..dc75635109d0f 100644 --- a/lib/web_ui/lib/src/engine/canvas_pool.dart +++ b/lib/web_ui/lib/src/engine/canvas_pool.dart @@ -96,7 +96,7 @@ class CanvasPool extends _SaveStackTracking { if (_canvas != null) { _restoreContextSave(); _contextHandle!.reset(); - _activeCanvasList ??= []; + _activeCanvasList ??= []; _activeCanvasList!.add(_canvas!); _canvas = null; _context = null; @@ -317,7 +317,7 @@ class CanvasPool extends _SaveStackTracking { if (_canvas != null) { _restoreContextSave(); _contextHandle!.reset(); - _activeCanvasList ??= []; + _activeCanvasList ??= []; _activeCanvasList!.add(_canvas!); _context = null; _contextHandle = null; diff --git a/lib/web_ui/lib/src/engine/canvaskit/color_filter.dart b/lib/web_ui/lib/src/engine/canvaskit/color_filter.dart index c4b0a00b8e3ee..8e5e6c28d2416 100644 --- a/lib/web_ui/lib/src/engine/canvaskit/color_filter.dart +++ b/lib/web_ui/lib/src/engine/canvaskit/color_filter.dart @@ -58,7 +58,7 @@ class ManagedSkColorFilter extends ManagedSkiaObject { /// [ManagedSkiaObject] that manages a skia image filter. abstract class CkColorFilter implements - CkManagedSkImageFilterConvertible, + CkManagedSkImageFilterConvertible, EngineColorFilter { const CkColorFilter(); diff --git a/lib/web_ui/lib/src/engine/canvaskit/embedded_views.dart b/lib/web_ui/lib/src/engine/canvaskit/embedded_views.dart index 8ff4b3193cb29..be07d5708dd95 100644 --- a/lib/web_ui/lib/src/engine/canvaskit/embedded_views.dart +++ b/lib/web_ui/lib/src/engine/canvaskit/embedded_views.dart @@ -99,14 +99,14 @@ class HtmlViewEmbedder { if (_viewsUsingBackupSurface.contains(viewId)) { if (_backupPictureRecorder == null) { // Only initialize the picture recorder for the backup surface once. - final pictureRecorder = CkPictureRecorder(); + final CkPictureRecorder pictureRecorder = CkPictureRecorder(); pictureRecorder.beginRecording(ui.Offset.zero & _frameSize); pictureRecorder.recordingCanvas!.clear(ui.Color(0x00000000)); _backupPictureRecorder = pictureRecorder; } _pictureRecorders[viewId] = _backupPictureRecorder!; } else { - final pictureRecorder = CkPictureRecorder(); + final CkPictureRecorder pictureRecorder = CkPictureRecorder(); pictureRecorder.beginRecording(ui.Offset.zero & _frameSize); pictureRecorder.recordingCanvas!.clear(ui.Color(0x00000000)); _pictureRecorders[viewId] = pictureRecorder; @@ -477,7 +477,7 @@ class HtmlViewEmbedder { /// Deletes SVG clip paths, useful for tests. void debugCleanupSvgClipPaths() { - _svgPathDefs?.children.single.children.forEach((element) { + _svgPathDefs?.children.single.children.forEach((html.Element element) { element.remove(); }); _svgClipDefs.clear(); diff --git a/lib/web_ui/lib/src/engine/canvaskit/font_fallbacks.dart b/lib/web_ui/lib/src/engine/canvaskit/font_fallbacks.dart index 1802400473c79..ee67d68f17af5 100644 --- a/lib/web_ui/lib/src/engine/canvaskit/font_fallbacks.dart +++ b/lib/web_ui/lib/src/engine/canvaskit/font_fallbacks.dart @@ -119,7 +119,7 @@ class FontFallbackData { final List codeUnits = runesToCheck.toList(); List fonts = []; - for (var font in fontFamilies) { + for (String font in fontFamilies) { List? typefacesForFamily = skiaFontCollection.familyToFontMap[font]; if (typefacesForFamily != null) { @@ -136,7 +136,7 @@ class FontFallbackData { } } - if (codeUnitsSupported.any((x) => !x)) { + if (codeUnitsSupported.any((bool x) => !x)) { List missingCodeUnits = []; for (int i = 0; i < codeUnitsSupported.length; i++) { if (!codeUnitsSupported[i]) { @@ -476,7 +476,7 @@ Set findMinimumFontsForCodeUnits( while (codeUnits.isNotEmpty) { int maxCodeUnitsCovered = 0; bestFonts.clear(); - for (var font in fonts) { + for (NotoFont font in fonts) { int codeUnitsCovered = 0; for (int codeUnit in codeUnits) { if (font.resolvedFont?.tree.containsDeep(codeUnit) == true) { @@ -499,7 +499,7 @@ Set findMinimumFontsForCodeUnits( // on locale. Otherwise just choose the first font. NotoFont bestFont = bestFonts.first; if (bestFonts.length > 1) { - if (bestFonts.every((font) => _cjkFonts.contains(font))) { + if (bestFonts.every((NotoFont font) => _cjkFonts.contains(font))) { if (language == 'zh-Hans' || language == 'zh-CN' || language == 'zh-SG' || @@ -524,7 +524,7 @@ Set findMinimumFontsForCodeUnits( } } } - codeUnits.removeWhere((codeUnit) { + codeUnits.removeWhere((int codeUnit) { return bestFont.resolvedFont!.tree.containsDeep(codeUnit); }); minimumFonts.addAll(bestFonts); diff --git a/lib/web_ui/lib/src/engine/canvaskit/fonts.dart b/lib/web_ui/lib/src/engine/canvaskit/fonts.dart index acaf37bd93cce..4008b2cb72a1a 100644 --- a/lib/web_ui/lib/src/engine/canvaskit/fonts.dart +++ b/lib/web_ui/lib/src/engine/canvaskit/fonts.dart @@ -40,14 +40,14 @@ class SkiaFontCollection { fontProvider = canvasKit.TypefaceFontProvider.Make(); familyToFontMap.clear(); - for (var font in _registeredFonts) { + for (RegisteredFont font in _registeredFonts) { fontProvider!.registerFont(font.bytes, font.family); familyToFontMap .putIfAbsent(font.family, () => []) .add(SkFont(font.typeface)); } - for (var font in FontFallbackData.instance.registeredFallbackFonts) { + for (RegisteredFont font in FontFallbackData.instance.registeredFallbackFonts) { fontProvider!.registerFont(font.bytes, font.family); familyToFontMap .putIfAbsent(font.family, () => []) @@ -162,7 +162,7 @@ class SkiaFontCollection { } String? _readActualFamilyName(Uint8List bytes) { - final SkFontMgr tmpFontMgr = canvasKit.FontMgr.FromData([bytes])!; + final SkFontMgr tmpFontMgr = canvasKit.FontMgr.FromData([bytes])!; String? actualFamily = tmpFontMgr.getFamilyName(0); tmpFontMgr.delete(); return actualFamily; @@ -195,6 +195,6 @@ class RegisteredFont { RegisteredFont(this.bytes, this.family, this.typeface) { // This is a hack which causes Skia to cache the decoded font. SkFont skFont = SkFont(typeface); - skFont.getGlyphBounds([0], null, null); + skFont.getGlyphBounds([0], null, null); } } diff --git a/lib/web_ui/lib/src/engine/canvaskit/image_filter.dart b/lib/web_ui/lib/src/engine/canvaskit/image_filter.dart index 990360995eb21..157fdcc7d592f 100644 --- a/lib/web_ui/lib/src/engine/canvaskit/image_filter.dart +++ b/lib/web_ui/lib/src/engine/canvaskit/image_filter.dart @@ -18,7 +18,7 @@ import '../util.dart'; /// whenever possible. /// /// Currently implemented by [CkImageFilter] and [CkColorFilter]. -abstract class CkManagedSkImageFilterConvertible +abstract class CkManagedSkImageFilterConvertible implements ui.ImageFilter { ManagedSkiaObject get imageFilter; } @@ -27,7 +27,7 @@ abstract class CkManagedSkImageFilterConvertible /// /// Currently only supports `blur`, `matrix`, and ColorFilters. abstract class CkImageFilter extends ManagedSkiaObject - implements CkManagedSkImageFilterConvertible { + implements CkManagedSkImageFilterConvertible { factory CkImageFilter.blur( {required double sigmaX, required double sigmaY, diff --git a/lib/web_ui/lib/src/engine/canvaskit/interval_tree.dart b/lib/web_ui/lib/src/engine/canvaskit/interval_tree.dart index 6d13316cf2eb0..c7df74a1112fe 100644 --- a/lib/web_ui/lib/src/engine/canvaskit/interval_tree.dart +++ b/lib/web_ui/lib/src/engine/canvaskit/interval_tree.dart @@ -73,7 +73,7 @@ class IntervalTree { IntervalTreeNode root = _makeBalancedTree(intervals)!; _computeHigh(root); - return IntervalTree._(root); + return IntervalTree._(root); } /// Returns the list of objects which have been associated with intervals that diff --git a/lib/web_ui/lib/src/engine/canvaskit/skia_object_cache.dart b/lib/web_ui/lib/src/engine/canvaskit/skia_object_cache.dart index 0619fcf8ed4b9..7b7156bd20d37 100644 --- a/lib/web_ui/lib/src/engine/canvaskit/skia_object_cache.dart +++ b/lib/web_ui/lib/src/engine/canvaskit/skia_object_cache.dart @@ -30,17 +30,17 @@ class SkiaObjectCache { /// A doubly linked list of the objects in the cache. /// /// This makes it fast to move a recently used object to the front. - final DoubleLinkedQueue _itemQueue; + final DoubleLinkedQueue> _itemQueue; /// A map of objects to their associated node in the [_itemQueue]. /// /// This makes it fast to find the node in the queue when we need to /// move the object to the front of the queue. - final Map> _itemMap; + final Map, DoubleLinkedQueueEntry>> _itemMap; SkiaObjectCache(this.maximumSize) - : _itemQueue = DoubleLinkedQueue(), - _itemMap = >{}; + : _itemQueue = DoubleLinkedQueue>(), + _itemMap = , DoubleLinkedQueueEntry>>{}; /// The number of objects in the cache. int get length => _itemQueue.length; @@ -49,7 +49,7 @@ class SkiaObjectCache { /// /// This is only for testing. @visibleForTesting - bool debugContains(SkiaObject object) { + bool debugContains(SkiaObject object) { return _itemMap.containsKey(object); } @@ -58,7 +58,7 @@ class SkiaObjectCache { /// If adding [object] causes the total size of the cache to exceed /// [maximumSize], then the least recently used half of the cache /// will be deleted. - void add(SkiaObject object) { + void add(SkiaObject object) { _itemQueue.addFirst(object); _itemMap[object] = _itemQueue.firstEntry()!; @@ -68,8 +68,8 @@ class SkiaObjectCache { } /// Records that [object] was used in the most recent frame. - void markUsed(SkiaObject object) { - DoubleLinkedQueueEntry item = _itemMap[object]!; + void markUsed(SkiaObject object) { + DoubleLinkedQueueEntry> item = _itemMap[object]!; item.remove(); _itemQueue.addFirst(object); _itemMap[object] = _itemQueue.firstEntry()!; @@ -79,7 +79,7 @@ class SkiaObjectCache { void resize() { final int itemsToDelete = maximumSize ~/ 2; for (int i = 0; i < itemsToDelete; i++) { - final SkiaObject oldObject = _itemQueue.removeLast(); + final SkiaObject oldObject = _itemQueue.removeLast(); _itemMap.remove(oldObject); oldObject.delete(); oldObject.didDelete(); @@ -96,17 +96,17 @@ class SynchronousSkiaObjectCache { /// A doubly linked list of the objects in the cache. /// /// This makes it fast to move a recently used object to the front. - final DoubleLinkedQueue _itemQueue; + final DoubleLinkedQueue> _itemQueue; /// A map of objects to their associated node in the [_itemQueue]. /// /// This makes it fast to find the node in the queue when we need to /// move the object to the front of the queue. - final Map> _itemMap; + final Map, DoubleLinkedQueueEntry>> _itemMap; SynchronousSkiaObjectCache(this.maximumSize) - : _itemQueue = DoubleLinkedQueue(), - _itemMap = >{}; + : _itemQueue = DoubleLinkedQueue>(), + _itemMap = , DoubleLinkedQueueEntry>>{}; /// The number of objects in the cache. int get length => _itemQueue.length; @@ -115,7 +115,7 @@ class SynchronousSkiaObjectCache { /// /// This is only for testing. @visibleForTesting - bool debugContains(SkiaObject object) { + bool debugContains(SkiaObject object) { return _itemMap.containsKey(object); } @@ -124,7 +124,7 @@ class SynchronousSkiaObjectCache { /// If adding [object] causes the total size of the cache to exceed /// [maximumSize], then the least recently used objects are evicted and /// deleted. - void add(SkiaObject object) { + void add(SkiaObject object) { assert( !_itemMap.containsKey(object), 'Cannot add object. Object is already in the cache: $object', @@ -139,8 +139,8 @@ class SynchronousSkiaObjectCache { /// If [object] is in the cache returns true. If the object is not in /// the cache, for example, because it was never added or because it was /// evicted as a result of the app reaching the cache limit, returns false. - bool markUsed(SkiaObject object) { - final DoubleLinkedQueueEntry? item = _itemMap[object]; + bool markUsed(SkiaObject object) { + final DoubleLinkedQueueEntry>? item = _itemMap[object]; if (item == null) { return false; @@ -158,7 +158,7 @@ class SynchronousSkiaObjectCache { /// Calls `delete` and `didDelete` on objects evicted from the cache. void _enforceCacheLimit() { while (_itemQueue.length > maximumSize) { - final SkiaObject oldObject = _itemQueue.removeLast(); + final SkiaObject oldObject = _itemQueue.removeLast(); _itemMap.remove(oldObject); oldObject.delete(); oldObject.didDelete(); @@ -512,8 +512,8 @@ class SkiaObjectBox /// Singleton that manages the lifecycles of [SkiaObject] instances. class SkiaObjects { @visibleForTesting - static final List resurrectableObjects = - []; + static final List> resurrectableObjects = + >[]; @visibleForTesting static int maximumCacheSize = 1024; @@ -543,7 +543,7 @@ class SkiaObjects { /// Starts managing the lifecycle of resurrectable [object]. /// /// These can safely be deleted at any time. - static void manageResurrectable(ManagedSkiaObject object) { + static void manageResurrectable(ManagedSkiaObject object) { registerCleanupCallback(); resurrectableObjects.add(object); } @@ -552,7 +552,7 @@ class SkiaObjects { /// /// Since it's expensive to resurrect, we shouldn't just delete it after every /// frame. Instead, add it to a cache and only delete it when the cache fills. - static void manageExpensive(SkiaObject object) { + static void manageExpensive(SkiaObject object) { registerCleanupCallback(); expensiveCache.add(object); } @@ -573,7 +573,7 @@ class SkiaObjects { } for (int i = 0; i < resurrectableObjects.length; i++) { - final SkiaObject object = resurrectableObjects[i]; + final SkiaObject object = resurrectableObjects[i]; object.delete(); object.didDelete(); } diff --git a/lib/web_ui/lib/src/engine/canvaskit/surface_factory.dart b/lib/web_ui/lib/src/engine/canvaskit/surface_factory.dart index f37074099fb66..0dfc4baccf2ef 100644 --- a/lib/web_ui/lib/src/engine/canvaskit/surface_factory.dart +++ b/lib/web_ui/lib/src/engine/canvaskit/surface_factory.dart @@ -62,11 +62,11 @@ class SurfaceFactory { /// released with [releaseSurface]. Surface getSurface() { if (_cache.isNotEmpty) { - final surface = _cache.removeLast(); + final Surface surface = _cache.removeLast(); _liveSurfaces.add(surface); return surface; } else if (debugSurfaceCount < maximumSurfaces) { - final surface = Surface(); + final Surface surface = Surface(); _liveSurfaces.add(surface); return surface; } else { diff --git a/lib/web_ui/lib/src/engine/canvaskit/text.dart b/lib/web_ui/lib/src/engine/canvaskit/text.dart index ea8e5e1c434c7..b54e3601a7ad5 100644 --- a/lib/web_ui/lib/src/engine/canvaskit/text.dart +++ b/lib/web_ui/lib/src/engine/canvaskit/text.dart @@ -428,7 +428,7 @@ class CkTextStyle implements ui.TextStyle { if (shadows != null) { List ckShadows = []; for (ui.Shadow shadow in shadows) { - final ckShadow = SkTextShadow(); + final SkTextShadow ckShadow = SkTextShadow(); ckShadow.color = makeFreshSkColor(shadow.color); ckShadow.offset = toSkPoint(shadow.offset); ckShadow.blurRadius = shadow.blurRadius; @@ -516,7 +516,7 @@ class CkStrutStyle implements ui.StrutStyle { } SkFontStyle toSkFontStyle(ui.FontWeight? fontWeight, ui.FontStyle? fontStyle) { - final style = SkFontStyle(); + final SkFontStyle style = SkFontStyle(); if (fontWeight != null) { style.weight = toSkFontWeight(fontWeight); } @@ -573,7 +573,7 @@ class CkParagraph extends SkiaObject implements ui.Paragraph { // existing object. bool didRebuildSkiaObject = false; if (paragraph == null) { - final builder = CkParagraphBuilder(_paragraphStyle); + final CkParagraphBuilder builder = CkParagraphBuilder(_paragraphStyle); for (_ParagraphCommand command in _paragraphCommands) { switch (command.type) { case _ParagraphCommandType.addText: @@ -893,7 +893,7 @@ class CkParagraphBuilder implements ui.ParagraphBuilder { double baselineOffset, ui.TextBaseline baseline, ) { - final properties = _CkParagraphPlaceholder( + final _CkParagraphPlaceholder properties = _CkParagraphPlaceholder( width: width, height: height, alignment: toSkPlaceholderAlignment(alignment), @@ -920,7 +920,7 @@ class CkParagraphBuilder implements ui.ParagraphBuilder { @override CkParagraph build() { - final builtParagraph = _buildSkParagraph(); + final SkParagraph builtParagraph = _buildSkParagraph(); return CkParagraph(builtParagraph, _style, _commands); } @@ -1054,7 +1054,7 @@ List _getEffectiveFontFamilies(String? fontFamily, fontFamilies.add(fontFamily); } if (fontFamilyFallback != null && - !fontFamilyFallback.every((font) => fontFamily == font)) { + !fontFamilyFallback.every((String font) => fontFamily == font)) { fontFamilies.addAll(fontFamilyFallback); } fontFamilies.addAll(FontFallbackData.instance.globalFontFallbacks); diff --git a/lib/web_ui/lib/src/engine/clipboard.dart b/lib/web_ui/lib/src/engine/clipboard.dart index 972c93b91908c..fb49e5315c98e 100644 --- a/lib/web_ui/lib/src/engine/clipboard.dart +++ b/lib/web_ui/lib/src/engine/clipboard.dart @@ -130,9 +130,9 @@ class ClipboardAPICopyStrategy implements CopyToClipboardStrategy { await html.window.navigator.clipboard!.writeText(text!); } catch (error) { print('copy is not successful $error'); - return Future.value(false); + return Future.value(false); } - return Future.value(true); + return Future.value(true); } } @@ -153,7 +153,7 @@ class ClipboardAPIPasteStrategy implements PasteFromClipboardStrategy { class ExecCommandCopyStrategy implements CopyToClipboardStrategy { @override Future setData(String? text) { - return Future.value(_setDataSync(text)); + return Future.value(_setDataSync(text)); } bool _setDataSync(String? text) { @@ -204,7 +204,7 @@ class ExecCommandPasteStrategy implements PasteFromClipboardStrategy { @override Future getData() { // TODO(nurhan): https://github.com/flutter/flutter/issues/48581 - return Future.error( + return Future.error( UnimplementedError('Paste is not implemented for this browser.')); } } diff --git a/lib/web_ui/lib/src/engine/dom_renderer.dart b/lib/web_ui/lib/src/engine/dom_renderer.dart index 91f53e608f58a..28faad610ea46 100644 --- a/lib/web_ui/lib/src/engine/dom_renderer.dart +++ b/lib/web_ui/lib/src/engine/dom_renderer.dart @@ -398,7 +398,7 @@ class DomRenderer { .instance.semanticsHelper .prepareAccessibilityPlaceholder(); - glassPaneElementHostNode.nodes.addAll([ + glassPaneElementHostNode.nodes.addAll([ semanticsHostElement, _accessibilityPlaceholder, _sceneHostElement!, @@ -489,7 +489,7 @@ class DomRenderer { // CommonJS is being used, and we shouldn't have any problems. js.JsFunction objectConstructor = js.context['Object']; if (js.context['exports'] == null) { - js.JsObject exportsAccessor = js.JsObject.jsify({ + js.JsObject exportsAccessor = js.JsObject.jsify({ 'get': js.allowInterop(() { if (html.document.currentScript == _canvasKitScript) { return js.JsObject(objectConstructor); @@ -506,7 +506,7 @@ class DomRenderer { [js.context, 'exports', exportsAccessor]); } if (js.context['module'] == null) { - js.JsObject moduleAccessor = js.JsObject.jsify({ + js.JsObject moduleAccessor = js.JsObject.jsify({ 'get': js.allowInterop(() { if (html.document.currentScript == _canvasKitScript) { return js.JsObject(objectConstructor); @@ -650,7 +650,7 @@ class DomRenderer { if (!unsafeIsNull(screenOrientation)) { if (orientations.isEmpty) { screenOrientation!.unlock(); - return Future.value(true); + return Future.value(true); } else { String? lockType = _deviceOrientationToLockType(orientations.first); if (lockType != null) { @@ -664,7 +664,7 @@ class DomRenderer { completer.complete(false); }); } catch (_) { - return Future.value(false); + return Future.value(false); } return completer.future; } @@ -672,7 +672,7 @@ class DomRenderer { } } // API is not supported on this browser return false. - return Future.value(false); + return Future.value(false); } // Converts device orientation to w3c OrientationLockType enum. diff --git a/lib/web_ui/lib/src/engine/frame_reference.dart b/lib/web_ui/lib/src/engine/frame_reference.dart index 1a4f8735de531..5aa250dec138a 100644 --- a/lib/web_ui/lib/src/engine/frame_reference.dart +++ b/lib/web_ui/lib/src/engine/frame_reference.dart @@ -66,8 +66,8 @@ class CrossFrameCache { } void _addToCache(String key, _CrossFrameCacheItem item) { - _cache ??= {}; - (_cache![key] ??= [])..add(item); + _cache ??= >>{}; + (_cache![key] ??= <_CrossFrameCacheItem>[])..add(item); } /// Given a key, consumes an item that has been cached in a prior frame. diff --git a/lib/web_ui/lib/src/engine/html/offscreen_canvas.dart b/lib/web_ui/lib/src/engine/html/offscreen_canvas.dart index 77cf2fafdb77d..1013d1b964072 100644 --- a/lib/web_ui/lib/src/engine/html/offscreen_canvas.dart +++ b/lib/web_ui/lib/src/engine/html/offscreen_canvas.dart @@ -74,8 +74,8 @@ class OffScreenCanvas { final Completer completer = Completer(); if (offScreenCanvas != null) { offScreenCanvas!.convertToBlob().then((html.Blob value) { - final fileReader = html.FileReader(); - fileReader.onLoad.listen((event) { + final html.FileReader fileReader = html.FileReader(); + fileReader.onLoad.listen((html.ProgressEvent event) { completer.complete(js_util.getProperty( js_util.getProperty(event, 'target')!, 'result')!); }); @@ -83,7 +83,7 @@ class OffScreenCanvas { }); return completer.future; } else { - return Future.value(canvasElement!.toDataUrl()); + return Future.value(canvasElement!.toDataUrl()); } } diff --git a/lib/web_ui/lib/src/engine/html/path/conic.dart b/lib/web_ui/lib/src/engine/html/path/conic.dart index 90502ddc27d66..a0a255a176d8c 100644 --- a/lib/web_ui/lib/src/engine/html/path/conic.dart +++ b/lib/web_ui/lib/src/engine/html/path/conic.dart @@ -327,9 +327,9 @@ class Conic { double p0, double p1, double p2, double w, double t) { assert(t >= 0 && t <= 1); final double src2w = p1 * w; - final C = p0; - final A = p2 - 2 * src2w + C; - final B = 2 * (src2w - C); + final double C = p0; + final double A = p2 - 2 * src2w + C; + final double B = 2 * (src2w - C); return polyEval(A, B, C, t); } diff --git a/lib/web_ui/lib/src/engine/html/path/path.dart b/lib/web_ui/lib/src/engine/html/path/path.dart index 75730ab904773..3735cf2f2b828 100644 --- a/lib/web_ui/lib/src/engine/html/path/path.dart +++ b/lib/web_ui/lib/src/engine/html/path/path.dart @@ -535,7 +535,7 @@ class SurfacePath implements ui.Path { // 180..270 -> quadrant 2 // 270..360 -> quadrant 3 - const List quadPoints = [ + const List quadPoints = [ ui.Offset(1, 0), ui.Offset(1, 1), ui.Offset(0, 1), @@ -564,7 +564,7 @@ class SurfacePath implements ui.Path { } } - List conics = []; + final List conics = []; const double quadrantWeight = SPath.scalarRoot2Over2; int conicCount = quadrant; @@ -1242,7 +1242,7 @@ class SurfacePath implements ui.Path { // points have identical tangents. final PathIterator iter = PathIterator(pathRef, true); final Float32List _buffer = Float32List(8 + 10); - List tangents = []; + final List tangents = []; bool done = false; do { int oldCount = tangents.length; diff --git a/lib/web_ui/lib/src/engine/html/path/path_metrics.dart b/lib/web_ui/lib/src/engine/html/path/path_metrics.dart index 4c624f3dbd970..14d222a1f4167 100644 --- a/lib/web_ui/lib/src/engine/html/path/path_metrics.dart +++ b/lib/web_ui/lib/src/engine/html/path/path_metrics.dart @@ -56,7 +56,7 @@ class _SurfacePathMeasure { final double resScale; final PathRef _path; PathIterator _pathIterator; - final List<_PathContourMeasure> _contours = []; + final List<_PathContourMeasure> _contours = <_PathContourMeasure>[]; // If the contour ends with a call to [Path.close] (which may // have been implied when using [Path.addRect]) @@ -138,7 +138,7 @@ class _PathContourMeasure { final PathRef pathRef; int _verbEndIndex = 0; - final List<_PathSegment> _segments = []; + final List<_PathSegment> _segments = <_PathSegment>[]; // Allocate buffer large enough for returning cubic curve chop result. // 2 floats for each coordinate x (start, end & control point 1 & 2). static final Float32List _buffer = Float32List(8); @@ -152,7 +152,7 @@ class _PathContourMeasure { bool _isClosed = false; ui.Tangent? getTangentForOffset(double distance) { - final segmentIndex = _segmentIndexAtDistance(distance); + final int segmentIndex = _segmentIndexAtDistance(distance); if (segmentIndex == -1) { return null; } @@ -297,8 +297,9 @@ class _PathContourMeasure { // actually made it larger, since a very small delta might be > 0, but // still have no effect on distance (if distance >>> delta). if (distance > prevDistance) { - _segments - .add(_PathSegment(SPath.kLineVerb, distance, [fromX, fromY, x, y])); + _segments.add( + _PathSegment(SPath.kLineVerb, distance, [fromX, fromY, x, y]), + ); } }; int verb = 0; diff --git a/lib/web_ui/lib/src/engine/html/path/path_ref.dart b/lib/web_ui/lib/src/engine/html/path/path_ref.dart index b9ffec9683bbd..32ed4d03470a8 100644 --- a/lib/web_ui/lib/src/engine/html/path/path_ref.dart +++ b/lib/web_ui/lib/src/engine/html/path/path_ref.dart @@ -421,8 +421,8 @@ class PathRef { resetToSize(verbCount, pointCount, weightCount, additionalReserveVerbs, additionalReservePoints); - js_util.callMethod(_fVerbs, 'set', [ref._fVerbs]); - js_util.callMethod(fPoints, 'set', [ref.fPoints]); + js_util.callMethod(_fVerbs, 'set', [ref._fVerbs]); + js_util.callMethod(fPoints, 'set', [ref.fPoints]); if (ref._conicWeights == null) { _conicWeights = null; } else { diff --git a/lib/web_ui/lib/src/engine/html/path/path_utils.dart b/lib/web_ui/lib/src/engine/html/path/path_utils.dart index 8591e816045d6..e72e03f4eeb9b 100644 --- a/lib/web_ui/lib/src/engine/html/path/path_utils.dart +++ b/lib/web_ui/lib/src/engine/html/path/path_utils.dart @@ -118,7 +118,7 @@ class QuadRoots { /// Returns roots as list. List get roots => (root0 == null) - ? [] + ? [] : (root1 == null ? [root0!] : [root0!, root1!]); int findRoots(double a, double b, double c) { diff --git a/lib/web_ui/lib/src/engine/html/path/path_windings.dart b/lib/web_ui/lib/src/engine/html/path/path_windings.dart index 380110d8ac0fa..d6dd12e6e12ee 100644 --- a/lib/web_ui/lib/src/engine/html/path/path_windings.dart +++ b/lib/web_ui/lib/src/engine/html/path/path_windings.dart @@ -224,12 +224,12 @@ class PathWinding { } void _computeConicWinding(double weight) { - Conic conic = Conic(_buffer[0], _buffer[1], _buffer[2], _buffer[3], + final Conic conic = Conic(_buffer[0], _buffer[1], _buffer[2], _buffer[3], _buffer[4], _buffer[5], weight); // If the data points are very large, the conic may not be monotonic but may also // fail to chop. Then, the chopper does not split the original conic in two. - bool isMono = _isQuadMonotonic(_buffer); - List conics = []; + final bool isMono = _isQuadMonotonic(_buffer); + final List conics = []; conic.chopAtYExtrema(conics); _computeMonoConicWinding(conics[0]); if (!isMono && conics.length == 2) { diff --git a/lib/web_ui/lib/src/engine/html/recording_canvas.dart b/lib/web_ui/lib/src/engine/html/recording_canvas.dart index 910cd72828fee..242e4558dca73 100644 --- a/lib/web_ui/lib/src/engine/html/recording_canvas.dart +++ b/lib/web_ui/lib/src/engine/html/recording_canvas.dart @@ -538,7 +538,7 @@ class RecordingCanvas { _didDraw = true; final double left = offset.dx; final double top = offset.dy; - final command = PaintDrawImage(image, offset, paint.paintData); + final PaintDrawImage command = PaintDrawImage(image, offset, paint.paintData); _paintBounds.growLTRB( left, top, left + image.width, top + image.height, command); _commands.add(command); diff --git a/lib/web_ui/lib/src/engine/html/shaders/shader.dart b/lib/web_ui/lib/src/engine/html/shaders/shader.dart index 1554a8b620721..0e4b8514421cf 100644 --- a/lib/web_ui/lib/src/engine/html/shaders/shader.dart +++ b/lib/web_ui/lib/src/engine/html/shaders/shader.dart @@ -195,8 +195,8 @@ class GradientLinear extends EngineGradient { if (matrix4 != null) { // The matrix is relative to shaderBounds so we shift center by // shaderBounds top-left origin. - final centerX = (from.dx + to.dx) / 2.0 - shaderBounds.left; - final centerY = (from.dy + to.dy) / 2.0 - shaderBounds.top; + final double centerX = (from.dx + to.dx) / 2.0 - shaderBounds.left; + final double centerY = (from.dy + to.dy) / 2.0 - shaderBounds.top; matrix4.transform(from.dx - centerX, from.dy - centerY); final double fromX = matrix4.transformedX + centerX; diff --git a/lib/web_ui/lib/src/engine/html/shaders/shader_builder.dart b/lib/web_ui/lib/src/engine/html/shaders/shader_builder.dart index ce584dab49d34..ade3fcb52de1d 100644 --- a/lib/web_ui/lib/src/engine/html/shaders/shader_builder.dart +++ b/lib/web_ui/lib/src/engine/html/shaders/shader_builder.dart @@ -30,8 +30,8 @@ import '../../util.dart'; class ShaderBuilder { /// WebGL version. final int version; - final List declarations = []; - final List _methods = []; + final List declarations = []; + final List _methods = []; /// Precision for integer variables. int? integerPrecision; @@ -241,7 +241,7 @@ class ShaderMethod { final String returnType = 'void'; final String name; - final List _statements = []; + final List _statements = []; int _indentLevel = 1; void indent() { @@ -362,7 +362,7 @@ class ShaderDeclaration { // These are used only in debug mode to assert if used as variable name. // https://www.khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.4.10.pdf -const List _kReservedWords = [ +const List _kReservedWords = [ 'attribute', 'const', 'uniform', diff --git a/lib/web_ui/lib/src/engine/html/surface.dart b/lib/web_ui/lib/src/engine/html/surface.dart index 86510c9c6d70f..c0eb292b0dcf9 100644 --- a/lib/web_ui/lib/src/engine/html/surface.dart +++ b/lib/web_ui/lib/src/engine/html/surface.dart @@ -180,7 +180,7 @@ class PersistedSurfaceException implements Exception { bool debugAssertSurfaceState( PersistedSurface surface, PersistedSurfaceState state1, [PersistedSurfaceState? state2, PersistedSurfaceState? state3]) { - final List validStates = [state1, state2, state3]; + final List validStates = [state1, state2, state3]; if (validStates.contains(surface.state)) { return true; diff --git a/lib/web_ui/lib/src/engine/html_image_codec.dart b/lib/web_ui/lib/src/engine/html_image_codec.dart index 8dfe8fb75f956..5b516dd1d8ce6 100644 --- a/lib/web_ui/lib/src/engine/html_image_codec.dart +++ b/lib/web_ui/lib/src/engine/html_image_codec.dart @@ -74,7 +74,7 @@ class HtmlCodec implements ui.Codec { return completer.future; } - void _decodeUsingOnLoad(Completer completer) { + void _decodeUsingOnLoad(Completer completer) { StreamSubscription? loadSubscription; late StreamSubscription errorSubscription; final html.ImageElement imgElement = html.ImageElement(); @@ -176,13 +176,13 @@ class HtmlImage implements ui.Image { final html.CanvasRenderingContext2D ctx = canvas.context2D; ctx.drawImage(imgElement, 0, 0); final html.ImageData imageData = ctx.getImageData(0, 0, width, height); - return Future.value(imageData.data.buffer.asByteData()); + return Future.value(imageData.data.buffer.asByteData()); } if (imgElement.src?.startsWith('data:') == true) { - final data = UriData.fromUri(Uri.parse(imgElement.src!)); - return Future.value(data.contentAsBytes().buffer.asByteData()); + final UriData data = UriData.fromUri(Uri.parse(imgElement.src!)); + return Future.value(data.contentAsBytes().buffer.asByteData()); } else { - return Future.value(null); + return Future.value(null); } } diff --git a/lib/web_ui/lib/src/engine/keyboard_binding.dart b/lib/web_ui/lib/src/engine/keyboard_binding.dart index 223902f85a832..8c0104c910550 100644 --- a/lib/web_ui/lib/src/engine/keyboard_binding.dart +++ b/lib/web_ui/lib/src/engine/keyboard_binding.dart @@ -29,7 +29,7 @@ const int _kLogicalMetaLeft = 0x0300000109; const int _kLogicalMetaRight = 0x0400000109; // Map logical keys for modifier keys to the functions that can get their // modifier flag out of an event. -final Map _kLogicalKeyToModifierGetter = { +final Map _kLogicalKeyToModifierGetter = { _kLogicalAltLeft: (FlutterHtmlKeyboardEvent event) => event.altKey, _kLogicalAltRight: (FlutterHtmlKeyboardEvent event) => event.altKey, _kLogicalControlLeft: (FlutterHtmlKeyboardEvent event) => event.ctrlKey, diff --git a/lib/web_ui/lib/src/engine/platform_dispatcher.dart b/lib/web_ui/lib/src/engine/platform_dispatcher.dart index 065d45e0ae359..36357a696f20d 100644 --- a/lib/web_ui/lib/src/engine/platform_dispatcher.dart +++ b/lib/web_ui/lib/src/engine/platform_dispatcher.dart @@ -383,7 +383,7 @@ class EnginePlatformDispatcher extends ui.PlatformDispatcher { // Also respond in HTML mode. Otherwise, apps would have to detect // CanvasKit vs HTML before invoking this method. replyToPlatformMessage( - callback, codec.encodeSuccessEnvelope([true])); + callback, codec.encodeSuccessEnvelope([true])); break; } return; @@ -715,11 +715,11 @@ class EnginePlatformDispatcher extends ui.PlatformDispatcher { static List parseBrowserLanguages() { // TODO(yjbanov): find a solution for IE - var languages = html.window.navigator.languages; + List? languages = html.window.navigator.languages; if (languages == null || languages.isEmpty) { // To make it easier for the app code, let's not leave the locales list // empty. This way there's fewer corner cases for apps to handle. - return const [_defaultLocale]; + return const [_defaultLocale]; } final List locales = []; diff --git a/lib/web_ui/lib/src/engine/platform_views/content_manager.dart b/lib/web_ui/lib/src/engine/platform_views/content_manager.dart index 5ce0c9863aa7c..88552a5dd51d4 100644 --- a/lib/web_ui/lib/src/engine/platform_views/content_manager.dart +++ b/lib/web_ui/lib/src/engine/platform_views/content_manager.dart @@ -38,10 +38,10 @@ typedef PlatformViewFactory = html.Element Function(int viewId); /// CRUD Platform Views as needed, regardless of the rendering backend. class PlatformViewManager { // The factory functions, indexed by the viewType - final Map _factories = {}; + final Map _factories = {}; // The references to content tags, indexed by their framework-given ID. - final Map _contents = {}; + final Map _contents = {}; /// Returns `true` if the passed in `viewType` has been registered before. /// diff --git a/lib/web_ui/lib/src/engine/pointer_binding.dart b/lib/web_ui/lib/src/engine/pointer_binding.dart index ee8d29843af24..667df68f308db 100644 --- a/lib/web_ui/lib/src/engine/pointer_binding.dart +++ b/lib/web_ui/lib/src/engine/pointer_binding.dart @@ -682,7 +682,7 @@ class _TouchAdapter extends _BaseAdapter { final Duration timeStamp = _BaseAdapter._eventTimeStampToDuration(event.timeStamp!); final List pointerData = []; for (html.Touch touch in event.changedTouches!) { - final nowPressed = _isTouchPressed(touch.identifier!); + final bool nowPressed = _isTouchPressed(touch.identifier!); if (!nowPressed) { _pressTouch(touch.identifier!); _convertEventToPointerData( @@ -702,7 +702,7 @@ class _TouchAdapter extends _BaseAdapter { final Duration timeStamp = _BaseAdapter._eventTimeStampToDuration(event.timeStamp!); final List pointerData = []; for (html.Touch touch in event.changedTouches!) { - final nowPressed = _isTouchPressed(touch.identifier!); + final bool nowPressed = _isTouchPressed(touch.identifier!); if (nowPressed) { _convertEventToPointerData( data: pointerData, @@ -723,7 +723,7 @@ class _TouchAdapter extends _BaseAdapter { final Duration timeStamp = _BaseAdapter._eventTimeStampToDuration(event.timeStamp!); final List pointerData = []; for (html.Touch touch in event.changedTouches!) { - final nowPressed = _isTouchPressed(touch.identifier!); + final bool nowPressed = _isTouchPressed(touch.identifier!); if (nowPressed) { _unpressTouch(touch.identifier!); _convertEventToPointerData( @@ -742,7 +742,7 @@ class _TouchAdapter extends _BaseAdapter { final Duration timeStamp = _BaseAdapter._eventTimeStampToDuration(event.timeStamp!); final List pointerData = []; for (html.Touch touch in event.changedTouches!) { - final nowPressed = _isTouchPressed(touch.identifier!); + final bool nowPressed = _isTouchPressed(touch.identifier!); if (nowPressed) { _unpressTouch(touch.identifier!); _convertEventToPointerData( diff --git a/lib/web_ui/lib/src/engine/semantics/semantics_helper.dart b/lib/web_ui/lib/src/engine/semantics/semantics_helper.dart index e98f33b01772c..956b9abcec485 100644 --- a/lib/web_ui/lib/src/engine/semantics/semantics_helper.dart +++ b/lib/web_ui/lib/src/engine/semantics/semantics_helper.dart @@ -334,7 +334,7 @@ class MobileSemanticsEnabler extends SemanticsEnabler { case 'pointerdown': case 'pointerup': final html.PointerEvent touch = event as html.PointerEvent; - activationPoint = new html.Point(touch.client.x, touch.client.y); + activationPoint = new html.Point(touch.client.x, touch.client.y); break; default: // The event is not relevant, forward to framework as normal. diff --git a/lib/web_ui/lib/src/engine/text/font_collection.dart b/lib/web_ui/lib/src/engine/text/font_collection.dart index 572c9fb715e7c..fbe2bae399602 100644 --- a/lib/web_ui/lib/src/engine/text/font_collection.dart +++ b/lib/web_ui/lib/src/engine/text/font_collection.dart @@ -197,7 +197,7 @@ class FontManager { // // TODO(mdebbar): Revert this once the dart:html type is fixed. // https://github.com/dart-lang/sdk/issues/45676 - js_util.callMethod(html.document.fonts!, 'add', [fontFace]); + js_util.callMethod(html.document.fonts!, 'add', [fontFace]); }, onError: (dynamic e) { printWarning('Error while trying to load font family "$family":\n$e'); })); diff --git a/lib/web_ui/lib/src/engine/text/ruler.dart b/lib/web_ui/lib/src/engine/text/ruler.dart index 21524eab262e8..36f1188f339f1 100644 --- a/lib/web_ui/lib/src/engine/text/ruler.dart +++ b/lib/web_ui/lib/src/engine/text/ruler.dart @@ -809,7 +809,7 @@ class ParagraphRuler { if (nodes.isEmpty) { return; } - final List childNodes = []; + final List childNodes = []; for (html.Node node in nodes) { if (node.nodeType == html.Node.TEXT_NODE) { textNodes.add(node); @@ -823,7 +823,7 @@ class ParagraphRuler { int position = 0; final List stack = nodes.reversed.toList(); while (true) { - var node = stack.removeLast(); + html.Node node = stack.removeLast(); stack.addAll(node.childNodes.reversed); if (node == endNode) { break; diff --git a/lib/web_ui/lib/src/engine/text_editing/autofill_hint.dart b/lib/web_ui/lib/src/engine/text_editing/autofill_hint.dart index 398da6692b065..3059f63ee110a 100644 --- a/lib/web_ui/lib/src/engine/text_editing/autofill_hint.dart +++ b/lib/web_ui/lib/src/engine/text_editing/autofill_hint.dart @@ -16,7 +16,7 @@ class BrowserAutofillHints { final Map _flutterToEngineMap; BrowserAutofillHints._() - : _flutterToEngineMap = { + : _flutterToEngineMap = { 'birthday': 'bday', 'birthdayDay': 'bday-day', 'birthdayMonth': 'bday-month', diff --git a/lib/web_ui/lib/src/engine/text_editing/text_editing.dart b/lib/web_ui/lib/src/engine/text_editing/text_editing.dart index 6c2e923c32d08..f3278ce72c5fe 100644 --- a/lib/web_ui/lib/src/engine/text_editing/text_editing.dart +++ b/lib/web_ui/lib/src/engine/text_editing/text_editing.dart @@ -174,7 +174,7 @@ class EngineAutofillForm { formElement.noValidate = true; formElement.method = 'post'; formElement.action = '#'; - formElement.addEventListener('submit', (e) { + formElement.addEventListener('submit', (html.Event e) { e.preventDefault(); }); @@ -182,7 +182,7 @@ class EngineAutofillForm { // We keep the ids in a list then sort them later, in case the text fields' // locations are re-ordered on the framework side. - final List ids = List.empty(growable: true); + final List ids = List.empty(growable: true); // The focused text editing element will not be created here. final AutofillInfo focusedElement = @@ -1311,7 +1311,7 @@ class FirefoxTextEditingStrategy extends GloballyPositionedTextEditingStrategy { // // After each keyup, the start/end values of the selection is compared to // the previously saved editing state. - subscriptions.add(activeDomElement.onKeyUp.listen((event) { + subscriptions.add(activeDomElement.onKeyUp.listen((html.KeyboardEvent event) { handleChange(event); })); diff --git a/lib/web_ui/lib/src/engine/util.dart b/lib/web_ui/lib/src/engine/util.dart index ad272c0bdf41b..d714618d8fd18 100644 --- a/lib/web_ui/lib/src/engine/util.dart +++ b/lib/web_ui/lib/src/engine/util.dart @@ -451,7 +451,7 @@ String? canonicalizeFontFamily(String? fontFamily) { /// Converts a list of [Offset] to a typed array of floats. Float32List offsetListToFloat32List(List offsetList) { final int length = offsetList.length; - final floatList = Float32List(length * 2); + final Float32List floatList = Float32List(length * 2); for (int i = 0, destIndex = 0; i < length; i++, destIndex += 2) { floatList[destIndex] = offsetList[i].dx; floatList[destIndex + 1] = offsetList[i].dy; diff --git a/lib/web_ui/test/canvaskit/canvaskit_api_test.dart b/lib/web_ui/test/canvaskit/canvaskit_api_test.dart index 5b48dad8275d3..c0f1de5c38420 100644 --- a/lib/web_ui/test/canvaskit/canvaskit_api_test.dart +++ b/lib/web_ui/test/canvaskit/canvaskit_api_test.dart @@ -332,10 +332,10 @@ void _shaderTests() { test('MakeRadialGradient', () { expect( canvasKit.Shader.MakeRadialGradient( - Float32List.fromList([1, 1]), + Float32List.fromList([1, 1]), 10.0, Uint32List.fromList([0xff000000, 0xffffffff]), - Float32List.fromList([0, 1]), + Float32List.fromList([0, 1]), canvasKit.TileMode.Repeat, toSkMatrixFromFloat32(Matrix4.identity().storage), 0, @@ -346,12 +346,12 @@ void _shaderTests() { test('MakeTwoPointConicalGradient', () { expect( canvasKit.Shader.MakeTwoPointConicalGradient( - Float32List.fromList([1, 1]), + Float32List.fromList([1, 1]), 10.0, - Float32List.fromList([1, 1]), + Float32List.fromList([1, 1]), 10.0, Uint32List.fromList([0xff000000, 0xffffffff]), - Float32List.fromList([0, 1]), + Float32List.fromList([0, 1]), canvasKit.TileMode.Repeat, toSkMatrixFromFloat32(Matrix4.identity().storage), 0, @@ -362,10 +362,10 @@ void _shaderTests() { SkShader _makeTestShader() { return canvasKit.Shader.MakeLinearGradient( - Float32List.fromList([0, 0]), - Float32List.fromList([1, 1]), + Float32List.fromList([0, 0]), + Float32List.fromList([1, 1]), Uint32List.fromList([0xff0000ff]), - Float32List.fromList([0, 1]), + Float32List.fromList([0, 1]), canvasKit.TileMode.Repeat, null, ); @@ -414,7 +414,7 @@ void _colorFilterTests() { test('MakeBlend', () { expect( canvasKit.ColorFilter.MakeBlend( - Float32List.fromList([0, 0, 0, 1]), + Float32List.fromList([0, 0, 0, 1]), canvasKit.BlendMode.SrcATop, ), isNotNull, @@ -584,11 +584,11 @@ void _toSkMatrixFromFloat32Tests() { void _toSkRectTests() { test('toSkRect', () { - expect(toSkRect(ui.Rect.fromLTRB(1, 2, 3, 4)), [1, 2, 3, 4]); + expect(toSkRect(ui.Rect.fromLTRB(1, 2, 3, 4)), [1, 2, 3, 4]); }); test('fromSkRect', () { - expect(fromSkRect(Float32List.fromList([1, 2, 3, 4])), + expect(fromSkRect(Float32List.fromList([1, 2, 3, 4])), ui.Rect.fromLTRB(1, 2, 3, 4)); }); @@ -604,7 +604,7 @@ void _toSkRectTests() { bottomRight: ui.Radius.elliptical(9, 10), bottomLeft: ui.Radius.elliptical(11, 12), )), - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], + [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], ); }); } @@ -851,10 +851,10 @@ void _pathTests() { SkVertices _testVertices() { return canvasKit.MakeVertices( canvasKit.VertexMode.Triangles, - Float32List.fromList([0, 0, 10, 10, 0, 20]), - Float32List.fromList([0, 0, 10, 10, 0, 20]), - Uint32List.fromList([0xffff0000, 0xff00ff00, 0xff0000ff]), - Uint16List.fromList([0, 1, 2]), + Float32List.fromList([0, 0, 10, 10, 0, 20]), + Float32List.fromList([0, 0, 10, 10, 0, 20]), + Uint32List.fromList([0xffff0000, 0xff00ff00, 0xff0000ff]), + Uint16List.fromList([0, 1, 2]), ); } @@ -913,7 +913,7 @@ void _canvasTests() { }); test('clear', () { - canvas.clear(Float32List.fromList([0, 0, 0, 0])); + canvas.clear(Float32List.fromList([0, 0, 0, 0])); }); test('clipPath', () { @@ -926,7 +926,7 @@ void _canvasTests() { test('clipRRect', () { canvas.clipRRect( - Float32List.fromList([0, 0, 100, 100, 1, 2, 3, 4, 5, 6, 7, 8]), + Float32List.fromList([0, 0, 100, 100, 1, 2, 3, 4, 5, 6, 7, 8]), canvasKit.ClipOp.Intersect, true, ); @@ -934,7 +934,7 @@ void _canvasTests() { test('clipRect', () { canvas.clipRect( - Float32List.fromList([0, 0, 100, 100]), + Float32List.fromList([0, 0, 100, 100]), canvasKit.ClipOp.Intersect, true, ); @@ -942,7 +942,7 @@ void _canvasTests() { test('drawArc', () { canvas.drawArc( - Float32List.fromList([0, 0, 100, 50]), + Float32List.fromList([0, 0, 100, 50]), 0, 100, true, @@ -955,8 +955,8 @@ void _canvasTests() { canvasKit.MakeAnimatedImageFromEncoded(kTransparentImage)!; canvas.drawAtlas( image.makeImageAtCurrentFrame(), - Float32List.fromList([0, 0, 1, 1]), - Float32List.fromList([1, 0, 2, 3]), + Float32List.fromList([0, 0, 1, 1]), + Float32List.fromList([1, 0, 2, 3]), SkPaint(), canvasKit.BlendMode.SrcOver, Uint32List.fromList([0xff000000, 0xffffffff]), @@ -973,8 +973,8 @@ void _canvasTests() { test('drawDRRect', () { canvas.drawDRRect( - Float32List.fromList([0, 0, 100, 100, 1, 2, 3, 4, 5, 6, 7, 8]), - Float32List.fromList([20, 20, 80, 80, 1, 2, 3, 4, 5, 6, 7, 8]), + Float32List.fromList([0, 0, 100, 100, 1, 2, 3, 4, 5, 6, 7, 8]), + Float32List.fromList([20, 20, 80, 80, 1, 2, 3, 4, 5, 6, 7, 8]), SkPaint(), ); }); @@ -1010,8 +1010,8 @@ void _canvasTests() { canvasKit.MakeAnimatedImageFromEncoded(kTransparentImage)!; canvas.drawImageRectOptions( image.makeImageAtCurrentFrame(), - Float32List.fromList([0, 0, 1, 1]), - Float32List.fromList([0, 0, 1, 1]), + Float32List.fromList([0, 0, 1, 1]), + Float32List.fromList([0, 0, 1, 1]), canvasKit.FilterMode.Linear, canvasKit.MipmapMode.None, SkPaint(), @@ -1023,8 +1023,8 @@ void _canvasTests() { canvasKit.MakeAnimatedImageFromEncoded(kTransparentImage)!; canvas.drawImageRectCubic( image.makeImageAtCurrentFrame(), - Float32List.fromList([0, 0, 1, 1]), - Float32List.fromList([0, 0, 1, 1]), + Float32List.fromList([0, 0, 1, 1]), + Float32List.fromList([0, 0, 1, 1]), 0.3, 0.3, SkPaint(), @@ -1036,8 +1036,8 @@ void _canvasTests() { canvasKit.MakeAnimatedImageFromEncoded(kTransparentImage)!; canvas.drawImageNine( image.makeImageAtCurrentFrame(), - Float32List.fromList([0, 0, 1, 1]), - Float32List.fromList([0, 0, 1, 1]), + Float32List.fromList([0, 0, 1, 1]), + Float32List.fromList([0, 0, 1, 1]), canvasKit.FilterMode.Linear, SkPaint(), ); @@ -1048,7 +1048,7 @@ void _canvasTests() { }); test('drawOval', () { - canvas.drawOval(Float32List.fromList([0, 0, 1, 1]), SkPaint()); + canvas.drawOval(Float32List.fromList([0, 0, 1, 1]), SkPaint()); }); test('drawPaint', () { @@ -1065,21 +1065,21 @@ void _canvasTests() { test('drawPoints', () { canvas.drawPoints( canvasKit.PointMode.Lines, - Float32List.fromList([0, 0, 10, 10, 0, 10]), + Float32List.fromList([0, 0, 10, 10, 0, 10]), SkPaint(), ); }); test('drawRRect', () { canvas.drawRRect( - Float32List.fromList([0, 0, 100, 100, 1, 2, 3, 4, 5, 6, 7, 8]), + Float32List.fromList([0, 0, 100, 100, 1, 2, 3, 4, 5, 6, 7, 8]), SkPaint(), ); }); test('drawRect', () { canvas.drawRect( - Float32List.fromList([0, 0, 100, 100]), + Float32List.fromList([0, 0, 100, 100]), SkPaint(), ); }); @@ -1155,7 +1155,7 @@ void _canvasTests() { test('drawPicture', () { final SkPictureRecorder otherRecorder = SkPictureRecorder(); final SkCanvas otherCanvas = - otherRecorder.beginRecording(Float32List.fromList([0, 0, 100, 100])); + otherRecorder.beginRecording(Float32List.fromList([0, 0, 100, 100])); otherCanvas.drawLine(0, 0, 10, 10, SkPaint()); canvas.drawPicture(otherRecorder.finishRecordingAsPicture()); }); @@ -1181,9 +1181,9 @@ void _canvasTests() { browserSupportsFinalizationRegistry = true; final SkPictureRecorder otherRecorder = SkPictureRecorder(); final SkCanvas otherCanvas = - otherRecorder.beginRecording(Float32List.fromList([0, 0, 1, 1])); + otherRecorder.beginRecording(Float32List.fromList([0, 0, 1, 1])); otherCanvas.drawRect( - Float32List.fromList([0, 0, 1, 1]), + Float32List.fromList([0, 0, 1, 1]), SkPaint(), ); final CkPicture picture = @@ -1423,8 +1423,8 @@ void _paragraphTests() { canvasKit.RectHeightStyle.Strut, canvasKit.RectWidthStyle.Tight, ), - [ - [0, 0, 13.770000457763672, 75], + >[ + [0, 0, 13.770000457763672, 75], ], ); }); diff --git a/lib/web_ui/test/canvaskit/color_filter_golden_test.dart b/lib/web_ui/test/canvaskit/color_filter_golden_test.dart index 0bb91726af4ae..1f20ed5948ea8 100644 --- a/lib/web_ui/test/canvaskit/color_filter_golden_test.dart +++ b/lib/web_ui/test/canvaskit/color_filter_golden_test.dart @@ -48,7 +48,7 @@ void testMain() { builder.addPicture(ui.Offset.zero, redCircle); // Apply a "greyscale" color filter. - builder.pushColorFilter(ui.ColorFilter.matrix([ + builder.pushColorFilter(ui.ColorFilter.matrix([ 0.2126, 0.7152, 0.0722, 0, 0, // 0.2126, 0.7152, 0.0722, 0, 0, // 0.2126, 0.7152, 0.0722, 0, 0, // diff --git a/lib/web_ui/test/canvaskit/embedded_views_test.dart b/lib/web_ui/test/canvaskit/embedded_views_test.dart index c650be89991b5..ea50f8e262495 100644 --- a/lib/web_ui/test/canvaskit/embedded_views_test.dart +++ b/lib/web_ui/test/canvaskit/embedded_views_test.dart @@ -29,7 +29,7 @@ void testMain() { test('embeds interactive platform views', () async { ui.platformViewRegistry.registerViewFactory( 'test-platform-view', - (viewId) => html.DivElement()..id = 'view-0', + (int viewId) => html.DivElement()..id = 'view-0', ); await _createPlatformView(0, 'test-platform-view'); @@ -43,10 +43,10 @@ void testMain() { // The platform view is now split in two parts. The contents live // as a child of the glassPane, and the slot lives in the glassPane // shadow root. The slot is the one that has pointer events auto. - final contents = domRenderer.glassPaneElement!.querySelector('#view-0')!; - final slot = domRenderer.sceneElement!.querySelector('slot')!; - final contentsHost = contents.parent!; - final slotHost = slot.parent!; + final html.Element contents = domRenderer.glassPaneElement!.querySelector('#view-0')!; + final html.Element slot = domRenderer.sceneElement!.querySelector('slot')!; + final html.Element contentsHost = contents.parent!; + final html.Element slotHost = slot.parent!; expect(contents, isNotNull, reason: 'The view from the factory is injected in the DOM.'); @@ -63,7 +63,7 @@ void testMain() { test('clips platform views with RRects', () async { ui.platformViewRegistry.registerViewFactory( 'test-platform-view', - (viewId) => html.DivElement()..id = 'view-0', + (int viewId) => html.DivElement()..id = 'view-0', ); await _createPlatformView(0, 'test-platform-view'); @@ -100,7 +100,7 @@ void testMain() { test('correctly transforms platform views', () async { ui.platformViewRegistry.registerViewFactory( 'test-platform-view', - (viewId) => html.DivElement()..id = 'view-0', + (int viewId) => html.DivElement()..id = 'view-0', ); await _createPlatformView(0, 'test-platform-view'); @@ -145,7 +145,7 @@ void testMain() { window.debugOverrideDevicePixelRatio(4); ui.platformViewRegistry.registerViewFactory( 'test-platform-view', - (viewId) => html.DivElement()..id = 'view-0', + (int viewId) => html.DivElement()..id = 'view-0', ); await _createPlatformView(0, 'test-platform-view'); @@ -172,7 +172,7 @@ void testMain() { window.debugOverrideDevicePixelRatio(4); ui.platformViewRegistry.registerViewFactory( 'test-platform-view', - (viewId) => html.DivElement()..id = 'view-0', + (int viewId) => html.DivElement()..id = 'view-0', ); await _createPlatformView(0, 'test-platform-view'); @@ -213,7 +213,7 @@ void testMain() { for (int i = 0; i < HtmlViewEmbedder.maximumOverlaySurfaces * 2; i++) { ui.platformViewRegistry.registerViewFactory( 'test-platform-view', - (viewId) => html.DivElement()..id = 'view-$i', + (int viewId) => html.DivElement()..id = 'view-$i', ); await _createPlatformView(i, 'test-platform-view'); platformViewIds.add(i); @@ -284,7 +284,7 @@ void testMain() { // Render: deleted platform views. // Expect: error. for (final int id in platformViewIds) { - final codec = StandardMethodCodec(); + final StandardMethodCodec codec = StandardMethodCodec(); final Completer completer = Completer(); ui.window.sendPlatformMessage( 'flutter/platform_views', @@ -318,7 +318,7 @@ void testMain() { test('embeds and disposes of a platform view', () async { ui.platformViewRegistry.registerViewFactory( 'test-platform-view', - (viewId) => html.DivElement()..id = 'view-0', + (int viewId) => html.DivElement()..id = 'view-0', ); await _createPlatformView(0, 'test-platform-view'); @@ -358,7 +358,7 @@ void testMain() { test('removed the DOM node of an unrendered platform view', () async { ui.platformViewRegistry.registerViewFactory( 'test-platform-view', - (viewId) => html.DivElement()..id = 'view-0', + (int viewId) => html.DivElement()..id = 'view-0', ); await _createPlatformView(0, 'test-platform-view'); @@ -416,7 +416,7 @@ void testMain() { () async { ui.platformViewRegistry.registerViewFactory( 'test-platform-view', - (viewId) => html.DivElement()..id = 'test-view', + (int viewId) => html.DivElement()..id = 'test-view', ); await _createPlatformView(0, 'test-platform-view'); @@ -454,7 +454,7 @@ void testMain() { // Sends a platform message to create a Platform View with the given id and viewType. Future _createPlatformView(int id, String viewType) { - final completer = Completer(); + final Completer completer = Completer(); window.sendPlatformMessage( 'flutter/platform_views', codec.encodeMethodCall(MethodCall( @@ -470,7 +470,7 @@ Future _createPlatformView(int id, String viewType) { } Future _disposePlatformView(int id) { - final completer = Completer(); + final Completer completer = Completer(); window.sendPlatformMessage( 'flutter/platform_views', codec.encodeMethodCall(MethodCall('dispose', id)), diff --git a/lib/web_ui/test/canvaskit/fallback_fonts_golden_test.dart b/lib/web_ui/test/canvaskit/fallback_fonts_golden_test.dart index 2f23439eda7df..e2b748ab8137d 100644 --- a/lib/web_ui/test/canvaskit/fallback_fonts_golden_test.dart +++ b/lib/web_ui/test/canvaskit/fallback_fonts_golden_test.dart @@ -87,7 +87,7 @@ void testMain() { } '''; - expect(FontFallbackData.instance.globalFontFallbacks, ['Roboto']); + expect(FontFallbackData.instance.globalFontFallbacks, ['Roboto']); // Creating this paragraph should cause us to start to download the // fallback font. @@ -153,7 +153,7 @@ void testMain() { } '''; - expect(FontFallbackData.instance.globalFontFallbacks, ['Roboto']); + expect(FontFallbackData.instance.globalFontFallbacks, ['Roboto']); // Creating this paragraph should cause us to start to download the // fallback font. @@ -195,7 +195,7 @@ void testMain() { 'https://fonts.googleapis.com/css2?family=Noto+Naskh+Arabic+UI'] = 'invalid CSS... this should cause our parser to fail'; - expect(FontFallbackData.instance.globalFontFallbacks, ['Roboto']); + expect(FontFallbackData.instance.globalFontFallbacks, ['Roboto']); // Creating this paragraph should cause us to start to download the // fallback font. @@ -210,7 +210,7 @@ void testMain() { await Future.delayed(Duration.zero); expect(notoDownloadQueue.isPending, isFalse); - expect(FontFallbackData.instance.globalFontFallbacks, ['Roboto']); + expect(FontFallbackData.instance.globalFontFallbacks, ['Roboto']); }); // Regression test for https://github.com/flutter/flutter/issues/75836 @@ -334,7 +334,7 @@ void testMain() { print( 'findMinimumFontsForCodeunits failed:\n' ' Code units: ${codeUnits.join(', ')}\n' - ' Fonts: ${fonts.map((f) => f.name).join(', ')}', + ' Fonts: ${fonts.map((NotoFont f) => f.name).join(', ')}', ); rethrow; } diff --git a/lib/web_ui/test/canvaskit/filter_test.dart b/lib/web_ui/test/canvaskit/filter_test.dart index df71dc8432b8c..e365344fc7eb0 100644 --- a/lib/web_ui/test/canvaskit/filter_test.dart +++ b/lib/web_ui/test/canvaskit/filter_test.dart @@ -82,11 +82,11 @@ void testMain() { final CkPaint paint = CkPaint(); paint.imageFilter = CkImageFilter.blur(sigmaX: 5, sigmaY: 10, tileMode: ui.TileMode.clamp); - final ManagedSkiaObject managedFilter = paint.imageFilter as ManagedSkiaObject; + final ManagedSkiaObject managedFilter = paint.imageFilter as ManagedSkiaObject; final Object skiaFilter = managedFilter.skiaObject; paint.imageFilter = CkImageFilter.blur(sigmaX: 5, sigmaY: 10, tileMode: ui.TileMode.clamp); - expect((paint.imageFilter as ManagedSkiaObject).skiaObject, same(skiaFilter)); + expect((paint.imageFilter as ManagedSkiaObject).skiaObject, same(skiaFilter)); }); // TODO: https://github.com/flutter/flutter/issues/60040 diff --git a/lib/web_ui/test/canvaskit/hot_restart_test.dart b/lib/web_ui/test/canvaskit/hot_restart_test.dart index f1aa63c23b3c8..306ef0bf00217 100644 --- a/lib/web_ui/test/canvaskit/hot_restart_test.dart +++ b/lib/web_ui/test/canvaskit/hot_restart_test.dart @@ -26,7 +26,7 @@ void testMain() { assetManager: WebOnlyMockAssetManager()); expect(windowFlutterCanvasKit, isNotNull); - var firstCanvasKitInstance = windowFlutterCanvasKit; + CanvasKit? firstCanvasKitInstance = windowFlutterCanvasKit; // Triggers a reset of the CanvasKit script element. DomRenderer(); diff --git a/lib/web_ui/test/canvaskit/image_test.dart b/lib/web_ui/test/canvaskit/image_test.dart index 73370d67d0103..8de15f2a20fc0 100644 --- a/lib/web_ui/test/canvaskit/image_test.dart +++ b/lib/web_ui/test/canvaskit/image_test.dart @@ -272,7 +272,7 @@ class TestHttpRequest implements html.HttpRequest { } @override - void addEventListener(String type, listener, [bool? useCapture]) { + void addEventListener(String type, html.EventListener? listener, [bool? useCapture]) { throw UnimplementedError(); } @@ -330,7 +330,7 @@ class TestHttpRequest implements html.HttpRequest { int get readyState => throw UnimplementedError(); @override - void removeEventListener(String type, listener, [bool? useCapture]) { + void removeEventListener(String type, html.EventListener? listener, [bool? useCapture]) { throw UnimplementedError(); } diff --git a/lib/web_ui/test/canvaskit/interval_tree_test.dart b/lib/web_ui/test/canvaskit/interval_tree_test.dart index d7e56447bdb5e..7622421133550 100644 --- a/lib/web_ui/test/canvaskit/interval_tree_test.dart +++ b/lib/web_ui/test/canvaskit/interval_tree_test.dart @@ -15,15 +15,15 @@ void main() { void testMain() { group('$IntervalTree', () { test('is balanced', () { - var ranges = >{ - 'A': [CodeunitRange(0, 5), CodeunitRange(6, 10)], - 'B': [CodeunitRange(4, 6)], + Map> ranges = >{ + 'A': [CodeunitRange(0, 5), CodeunitRange(6, 10)], + 'B': [CodeunitRange(4, 6)], }; // Should create a balanced 3-node tree with a root with a left and right // child. - var tree = IntervalTree.createFromRanges(ranges); - var root = tree.root; + IntervalTree tree = IntervalTree.createFromRanges(ranges); + IntervalTreeNode root = tree.root; expect(root.left, isNotNull); expect(root.right, isNotNull); expect(root.left!.left, isNull); @@ -32,8 +32,8 @@ void testMain() { expect(root.right!.right, isNull); // Should create a balanced 15-node tree (4 layers deep). - var ranges2 = >{ - 'A': [ + Map> ranges2 = >{ + 'A': [ CodeunitRange(1, 1), CodeunitRange(2, 2), CodeunitRange(3, 3), @@ -54,8 +54,8 @@ void testMain() { // Should create a balanced 3-node tree with a root with a left and right // child. - var tree2 = IntervalTree.createFromRanges(ranges2); - var root2 = tree2.root; + IntervalTree tree2 = IntervalTree.createFromRanges(ranges2); + IntervalTreeNode root2 = tree2.root; expect(root2.left!.left!.left, isNotNull); expect(root2.left!.left!.right, isNotNull); @@ -68,16 +68,16 @@ void testMain() { }); test('finds values whose intervals overlap with a given point', () { - var ranges = >{ - 'A': [CodeunitRange(0, 5), CodeunitRange(7, 10)], - 'B': [CodeunitRange(4, 6)], + Map> ranges = >{ + 'A': [CodeunitRange(0, 5), CodeunitRange(7, 10)], + 'B': [CodeunitRange(4, 6)], }; - var tree = IntervalTree.createFromRanges(ranges); + IntervalTree tree = IntervalTree.createFromRanges(ranges); - expect(tree.intersections(1), ['A']); - expect(tree.intersections(4), ['A', 'B']); - expect(tree.intersections(6), ['B']); - expect(tree.intersections(7), ['A']); + expect(tree.intersections(1), ['A']); + expect(tree.intersections(4), ['A', 'B']); + expect(tree.intersections(6), ['B']); + expect(tree.intersections(7), ['A']); expect(tree.intersections(11), []); }); }); diff --git a/lib/web_ui/test/canvaskit/platform_dispatcher_test.dart b/lib/web_ui/test/canvaskit/platform_dispatcher_test.dart index dc923bfa89194..e81a40b068a60 100644 --- a/lib/web_ui/test/canvaskit/platform_dispatcher_test.dart +++ b/lib/web_ui/test/canvaskit/platform_dispatcher_test.dart @@ -37,7 +37,7 @@ void testMain() { expect(response, isNotNull); expect( codec.decodeEnvelope(response!), - [true], + [true], ); }); // TODO: https://github.com/flutter/flutter/issues/60040 diff --git a/lib/web_ui/test/canvaskit/skia_objects_cache_test.dart b/lib/web_ui/test/canvaskit/skia_objects_cache_test.dart index b3aa90e695f28..480fa0543d3e3 100644 --- a/lib/web_ui/test/canvaskit/skia_objects_cache_test.dart +++ b/lib/web_ui/test/canvaskit/skia_objects_cache_test.dart @@ -140,7 +140,7 @@ void _tests() { spy.fakeAsync.elapse(const Duration(seconds: 2)); expect( spy.printLog, - [ + [ 'Engine counters:\n' ' TestSkDeletable created: 1\n' ], @@ -167,7 +167,7 @@ void _tests() { spy.fakeAsync.elapse(const Duration(seconds: 2)); expect( spy.printLog, - [ + [ 'Engine counters:\n' ' TestSkDeletable created: 1\n' ' TestSkDeletable deleted: 1\n' diff --git a/lib/web_ui/test/canvaskit/vertices_test.dart b/lib/web_ui/test/canvaskit/vertices_test.dart index f0ec6adc8fde1..42c6bdf13d988 100644 --- a/lib/web_ui/test/canvaskit/vertices_test.dart +++ b/lib/web_ui/test/canvaskit/vertices_test.dart @@ -23,8 +23,8 @@ void testMain() { expect(vertices.createDefault(), isNotNull); expect(vertices.resurrect(), isNotNull); - final recorder = CkPictureRecorder(); - final canvas = recorder.beginRecording(const ui.Rect.fromLTRB(0, 0, 100, 100)); + final CkPictureRecorder recorder = CkPictureRecorder(); + final CkCanvas canvas = recorder.beginRecording(const ui.Rect.fromLTRB(0, 0, 100, 100)); canvas.drawVertices( vertices, ui.BlendMode.srcOver, diff --git a/lib/web_ui/test/clipboard_test.dart b/lib/web_ui/test/clipboard_test.dart index a54ce4f1a9446..3a025433dc224 100644 --- a/lib/web_ui/test/clipboard_test.dart +++ b/lib/web_ui/test/clipboard_test.dart @@ -70,7 +70,7 @@ void testMain() async { expect( () =>codec.decodeEnvelope(result), throwsA(TypeMatcher() - .having((e) => e.code, 'code', equals('copy_fail')))); + .having((PlatformException e) => e.code, 'code', equals('copy_fail')))); }); test('get data successful', () async { diff --git a/lib/web_ui/test/engine/frame_reference_test.dart b/lib/web_ui/test/engine/frame_reference_test.dart index d0719a64159f5..3de0e0e798aff 100644 --- a/lib/web_ui/test/engine/frame_reference_test.dart +++ b/lib/web_ui/test/engine/frame_reference_test.dart @@ -13,14 +13,14 @@ void main() { void testMain() { group('CrossFrameCache', () { test('Reuse returns no object when cache empty', () { - final CrossFrameCache cache = CrossFrameCache(); + final CrossFrameCache cache = CrossFrameCache(); cache.commitFrame(); TestItem? requestedItem = cache.reuse('item1'); expect(requestedItem, null); }); test('Reuses object across frames', () { - final CrossFrameCache cache = CrossFrameCache(); + final CrossFrameCache cache = CrossFrameCache(); final TestItem testItem1 = TestItem('item1'); cache.cache(testItem1.label, testItem1); cache.commitFrame(); @@ -31,7 +31,7 @@ void testMain() { }); test('Reuses objects that have same key across frames', () { - final CrossFrameCache cache = CrossFrameCache(); + final CrossFrameCache cache = CrossFrameCache(); final TestItem testItem1 = TestItem('sameLabel'); final TestItem testItem2 = TestItem('sameLabel'); final TestItem testItemX = TestItem('X'); @@ -48,7 +48,7 @@ void testMain() { }); test('Values don\'t survive beyond next frame', () { - final CrossFrameCache cache = CrossFrameCache(); + final CrossFrameCache cache = CrossFrameCache(); final TestItem testItem1 = TestItem('item1'); cache.cache(testItem1.label, testItem1); cache.commitFrame(); @@ -58,8 +58,8 @@ void testMain() { }); test('Values are evicted when not reused', () { - final Set _evictedItems = {}; - final CrossFrameCache cache = CrossFrameCache(); + final Set _evictedItems = {}; + final CrossFrameCache cache = CrossFrameCache(); final TestItem testItem1 = TestItem('item1'); final TestItem testItem2 = TestItem('item2'); cache.cache(testItem1.label, testItem1, (TestItem item) {_evictedItems.add(item);}); diff --git a/lib/web_ui/test/engine/host_node_test.dart b/lib/web_ui/test/engine/host_node_test.dart index 62271f6878d40..f903befa982ca 100644 --- a/lib/web_ui/test/engine/host_node_test.dart +++ b/lib/web_ui/test/engine/host_node_test.dart @@ -55,7 +55,7 @@ void _runDomTests(HostNode hostNode) { final html.Element target = html.document.createElement('div')..id = 'yep'; setUp(() { - hostNode.nodes.addAll([ + hostNode.nodes.addAll([ html.document.createElement('div'), target, html.document.createElement('span'), diff --git a/lib/web_ui/test/engine/platform_dispatcher_test.dart b/lib/web_ui/test/engine/platform_dispatcher_test.dart index c3fb5c7d5f7f6..622210d46a19d 100644 --- a/lib/web_ui/test/engine/platform_dispatcher_test.dart +++ b/lib/web_ui/test/engine/platform_dispatcher_test.dart @@ -35,7 +35,7 @@ void testMain() { expect(response, isNotNull); expect( codec.decodeEnvelope(response!), - [true], + [true], ); }); diff --git a/lib/web_ui/test/engine/platform_views/message_handler_test.dart b/lib/web_ui/test/engine/platform_views/message_handler_test.dart index 90b714926c96d..df7977d5af977 100644 --- a/lib/web_ui/test/engine/platform_views/message_handler_test.dart +++ b/lib/web_ui/test/engine/platform_views/message_handler_test.dart @@ -35,7 +35,7 @@ void testMain() { group('"create" message', () { test('unregistered viewType, fails with descriptive exception', () async { - final messageHandler = PlatformViewMessageHandler( + final PlatformViewMessageHandler messageHandler = PlatformViewMessageHandler( contentManager: contentManager, ); final ByteData? message = _getCreateMessage(viewType, viewId); @@ -55,7 +55,7 @@ void testMain() { contentManager.registerFactory( viewType, (int id) => html.DivElement()); contentManager.renderContent(viewType, viewId, null); - final messageHandler = PlatformViewMessageHandler( + final PlatformViewMessageHandler messageHandler = PlatformViewMessageHandler( contentManager: contentManager, ); final ByteData? message = _getCreateMessage(viewType, viewId); @@ -75,7 +75,7 @@ void testMain() { () async { contentManager.registerFactory( viewType, (int id) => html.DivElement()..id = 'success'); - final messageHandler = PlatformViewMessageHandler( + final PlatformViewMessageHandler messageHandler = PlatformViewMessageHandler( contentManager: contentManager, ); final ByteData? message = _getCreateMessage(viewType, viewId); @@ -92,7 +92,7 @@ void testMain() { () async { contentManager.registerFactory( viewType, (int id) => html.DivElement()..id = 'success'); - final messageHandler = PlatformViewMessageHandler( + final PlatformViewMessageHandler messageHandler = PlatformViewMessageHandler( contentManager: contentManager, contentHandler: contentCompleter.complete, ); @@ -120,7 +120,7 @@ void testMain() { }); test('never fails, even for unknown viewIds', () async { - final messageHandler = PlatformViewMessageHandler( + final PlatformViewMessageHandler messageHandler = PlatformViewMessageHandler( contentManager: contentManager, ); final ByteData? message = _getDisposeMessage(viewId); @@ -134,7 +134,7 @@ void testMain() { }); test('never fails, even for unknown viewIds', () async { - final messageHandler = PlatformViewMessageHandler( + final PlatformViewMessageHandler messageHandler = PlatformViewMessageHandler( contentManager: _FakePlatformViewManager(viewIdCompleter.complete), ); final ByteData? message = _getDisposeMessage(viewId); @@ -166,7 +166,7 @@ class _FakePlatformViewManager extends PlatformViewManager { ByteData? _getCreateMessage(String viewType, int viewId) { return codec.encodeMethodCall(MethodCall( 'create', - { + { 'id': viewId, 'viewType': viewType, }, diff --git a/lib/web_ui/test/engine/pointer_binding_test.dart b/lib/web_ui/test/engine/pointer_binding_test.dart index 64824de1ba510..d15b1bfae29a9 100644 --- a/lib/web_ui/test/engine/pointer_binding_test.dart +++ b/lib/web_ui/test/engine/pointer_binding_test.dart @@ -404,7 +404,7 @@ void testMain() { // ALL ADAPTERS _testEach<_BasicEventContext>( - [ + <_BasicEventContext>[ _PointerEventContext(), _MouseEventContext(), _TouchEventContext(), @@ -425,7 +425,7 @@ void testMain() { ); _testEach<_BasicEventContext>( - [ + <_BasicEventContext>[ _PointerEventContext(), _MouseEventContext(), _TouchEventContext(), @@ -449,7 +449,7 @@ void testMain() { ); _testEach<_ButtonedEventMixin>( - [ + <_ButtonedEventMixin>[ if (!isIosSafari) _PointerEventContext(), if (!isIosSafari) _MouseEventContext(), ], @@ -523,7 +523,7 @@ void testMain() { // BUTTONED ADAPTERS _testEach<_ButtonedEventMixin>( - [ + <_ButtonedEventMixin>[ _PointerEventContext(), _MouseEventContext(), ], @@ -547,7 +547,7 @@ void testMain() { ); _testEach<_ButtonedEventMixin>( - [ + <_ButtonedEventMixin>[ _PointerEventContext(), _MouseEventContext(), ], @@ -584,7 +584,7 @@ void testMain() { ); _testEach<_ButtonedEventMixin>( - [ + <_ButtonedEventMixin>[ if (!isIosSafari) _PointerEventContext(), if (!isIosSafari) _MouseEventContext(), ], @@ -703,7 +703,7 @@ void testMain() { ); _testEach<_ButtonedEventMixin>( - [ + <_ButtonedEventMixin>[ if (!isIosSafari) _PointerEventContext(), if (!isIosSafari) _MouseEventContext() ], @@ -831,7 +831,7 @@ void testMain() { ); _testEach<_ButtonedEventMixin>( - [ + <_ButtonedEventMixin>[ if (!isIosSafari) _PointerEventContext(), if (!isIosSafari) _MouseEventContext(), ], @@ -1001,7 +1001,7 @@ void testMain() { ); _testEach<_ButtonedEventMixin>( - [ + <_ButtonedEventMixin>[ _PointerEventContext(), _MouseEventContext(), ], @@ -1066,7 +1066,7 @@ void testMain() { ); _testEach<_ButtonedEventMixin>( - [ + <_ButtonedEventMixin>[ if (!isIosSafari) _PointerEventContext(), if (!isIosSafari) _MouseEventContext(), ], @@ -1149,7 +1149,7 @@ void testMain() { ); _testEach<_ButtonedEventMixin>( - [ + <_ButtonedEventMixin>[ _PointerEventContext(), _MouseEventContext(), ], @@ -1222,7 +1222,7 @@ void testMain() { ); _testEach<_ButtonedEventMixin>( - [ + <_ButtonedEventMixin>[ _PointerEventContext(), ], 'correctly handles missing right mouse button up when followed by move', @@ -1273,7 +1273,7 @@ void testMain() { ); _testEach<_ButtonedEventMixin>( - [ + <_ButtonedEventMixin>[ _PointerEventContext(), _MouseEventContext(), ], @@ -1309,7 +1309,7 @@ void testMain() { ); _testEach<_ButtonedEventMixin>( - [ + <_ButtonedEventMixin>[ _PointerEventContext(), _MouseEventContext(), ], @@ -1366,7 +1366,7 @@ void testMain() { ); _testEach<_ButtonedEventMixin>( - [ + <_ButtonedEventMixin>[ _PointerEventContext(), _MouseEventContext(), ], @@ -1435,7 +1435,7 @@ void testMain() { ); _testEach<_ButtonedEventMixin>( - [ + <_ButtonedEventMixin>[ _PointerEventContext(), _MouseEventContext(), ], @@ -1508,7 +1508,7 @@ void testMain() { ); _testEach<_ButtonedEventMixin>( - [ + <_ButtonedEventMixin>[ _PointerEventContext(), _MouseEventContext(), ], @@ -1591,7 +1591,7 @@ void testMain() { ); _testEach<_ButtonedEventMixin>( - [ + <_ButtonedEventMixin>[ _PointerEventContext(), _MouseEventContext(), ], @@ -1661,7 +1661,7 @@ void testMain() { ); _testEach<_ButtonedEventMixin>( - [ + <_ButtonedEventMixin>[ _PointerEventContext(), _MouseEventContext(), ], @@ -1745,7 +1745,7 @@ void testMain() { ); _testEach<_ButtonedEventMixin>( - [ + <_ButtonedEventMixin>[ if (!isIosSafari) _PointerEventContext(), if (!isIosSafari) _MouseEventContext(), ], @@ -1812,7 +1812,7 @@ void testMain() { // MULTIPOINTER ADAPTERS _testEach<_MultiPointerEventMixin>( - [ + <_MultiPointerEventMixin>[ if (!isIosSafari) _PointerEventContext(), if (!isIosSafari) _TouchEventContext(), ], @@ -2003,7 +2003,7 @@ void testMain() { ); _testEach<_MultiPointerEventMixin>( - [ + <_MultiPointerEventMixin>[ if (!isIosSafari) _PointerEventContext(), if (!isIosSafari) _TouchEventContext(), ], @@ -2050,7 +2050,7 @@ void testMain() { // POINTER ADAPTER _testEach<_PointerEventContext>( - [ + <_PointerEventContext>[ if (!isIosSafari) _PointerEventContext(), ], 'does not synthesize pointer up if from different device', @@ -2090,7 +2090,7 @@ void testMain() { ); _testEach<_PointerEventContext>( - [ + <_PointerEventContext>[ _PointerEventContext(), ], 'handles random pointer id on up events', @@ -2145,8 +2145,8 @@ void testMain() { // TOUCH ADAPTER - _testEach( - [ + _testEach<_TouchEventContext>( + <_TouchEventContext>[ if (!isIosSafari) _TouchEventContext(), ], 'does calculate delta and pointer identifier correctly', diff --git a/lib/web_ui/test/engine/semantics/semantics_test.dart b/lib/web_ui/test/engine/semantics/semantics_test.dart index d59107036f40d..43c900ce9de1b 100644 --- a/lib/web_ui/test/engine/semantics/semantics_test.dart +++ b/lib/web_ui/test/engine/semantics/semantics_test.dart @@ -242,7 +242,7 @@ void _testEngineSemanticsOwner() { // Verify the interactions. expect( mockSemanticsEnabler.shouldEnableSemanticsEvents, - [pointerEvent], + [pointerEvent], ); }); diff --git a/lib/web_ui/test/engine/surface/platform_view_test.dart b/lib/web_ui/test/engine/surface/platform_view_test.dart index 6e748145ddd47..9cdd14ad666c4 100644 --- a/lib/web_ui/test/engine/surface/platform_view_test.dart +++ b/lib/web_ui/test/engine/surface/platform_view_test.dart @@ -27,14 +27,14 @@ void testMain() { setUp(() async { platformViewRegistry.registerViewFactory( 'test-0', - (viewId) => html.DivElement(), + (int viewId) => html.DivElement(), ); platformViewRegistry.registerViewFactory( 'test-1', - (viewId) => html.DivElement(), + (int viewId) => html.DivElement(), ); // Ensure the views are created... - await Future.wait([ + await Future.wait(>[ _createPlatformView(0, 'test-0'), _createPlatformView(1, 'test-1'), ]); @@ -43,7 +43,7 @@ void testMain() { group('update', () { test('throws assertion error if called with different viewIds', () { - final differentView = PersistedPlatformView(1, 1, 1, 100, 100)..build(); + final PersistedPlatformView differentView = PersistedPlatformView(1, 1, 1, 100, 100)..build(); expect(() { view.update(differentView); }, throwsAssertionError); @@ -52,24 +52,24 @@ void testMain() { group('canUpdateAsMatch', () { test('returns true when viewId is the same', () { - final sameView = PersistedPlatformView(0, 1, 1, 100, 100)..build(); + final PersistedPlatformView sameView = PersistedPlatformView(0, 1, 1, 100, 100)..build(); expect(view.canUpdateAsMatch(sameView), isTrue); }); test('returns false when viewId is different', () { - final differentView = PersistedPlatformView(1, 1, 1, 100, 100)..build(); + final PersistedPlatformView differentView = PersistedPlatformView(1, 1, 1, 100, 100)..build(); expect(view.canUpdateAsMatch(differentView), isFalse); }); test('returns false when other view is not a PlatformView', () { - final anyView = PersistedOpacity(null, 1, Offset(0, 0))..build(); + final PersistedOpacity anyView = PersistedOpacity(null, 1, Offset(0, 0))..build(); expect(view.canUpdateAsMatch(anyView), isFalse); }); }); group('createElement', () { test('creates slot element that can receive pointer events', () { - final element = view.createElement(); + final html.Element element = view.createElement(); expect(element.tagName, equalsIgnoringCase('flt-platform-view-slot')); expect(element.style.pointerEvents, 'auto'); @@ -80,7 +80,7 @@ void testMain() { // Sends a platform message to create a Platform View with the given id and viewType. Future _createPlatformView(int id, String viewType) { - final completer = Completer(); + final Completer completer = Completer(); window.sendPlatformMessage( 'flutter/platform_views', codec.encodeMethodCall(MethodCall( diff --git a/lib/web_ui/test/engine/surface/scene_builder_test.dart b/lib/web_ui/test/engine/surface/scene_builder_test.dart index da97b161a7619..8771ab11e302d 100644 --- a/lib/web_ui/test/engine/surface/scene_builder_test.dart +++ b/lib/web_ui/test/engine/surface/scene_builder_test.dart @@ -496,7 +496,7 @@ void testMain() { // Watches DOM mutations and counts deletions and additions to the child // list of the `` element. - final html.MutationObserver observer = html.MutationObserver((List mutations, _) { + final html.MutationObserver observer = html.MutationObserver((List mutations, _) { for (html.MutationRecord record in mutations.cast()) { actualDeletions.addAll(record.removedNodes!); actualAdditions.addAll(record.addedNodes!); @@ -513,10 +513,10 @@ void testMain() { final List pTags = scene.webOnlyRootElement!.querySelectorAll('p'); expect(pTags, hasLength(string.length)); expect( - scene.webOnlyRootElement!.querySelectorAll('p').map((p) => p.innerText).join(''), + scene.webOnlyRootElement!.querySelectorAll('p').map((html.Element p) => p.innerText).join(''), string, ); - renderedLayers.removeWhere((key, value) => !string.contains(key)); + renderedLayers.removeWhere((String key, ui.EngineLayer value) => !string.contains(key)); // Inject a zero-duration timer to allow mutation observers to receive notification. return Future.delayed(Duration.zero).then((_) { @@ -821,10 +821,12 @@ ui.Picture _drawPicture() { final RecordingCanvas canvas = recorder.beginRecording(const ui.Rect.fromLTRB(0, 0, 400, 400)); ui.Shader gradient = ui.Gradient.radial( - ui.Offset(100, 100), 50, [ - const ui.Color.fromARGB(255, 0, 0, 0), - const ui.Color.fromARGB(255, 0, 0, 255) - ]); + ui.Offset(100, 100), 50, + [ + const ui.Color.fromARGB(255, 0, 0, 0), + const ui.Color.fromARGB(255, 0, 0, 255), + ], + ); canvas.drawCircle( ui.Offset(offsetX + 10, offsetY + 10), 10, SurfacePaint() @@ -864,10 +866,12 @@ EnginePicture _drawPathImagePath() { final RecordingCanvas canvas = recorder.beginRecording(const ui.Rect.fromLTRB(0, 0, 400, 400)); ui.Shader gradient = ui.Gradient.radial( - ui.Offset(100, 100), 50, [ - const ui.Color.fromARGB(255, 0, 0, 0), - const ui.Color.fromARGB(255, 0, 0, 255) - ]); + ui.Offset(100, 100), 50, + [ + const ui.Color.fromARGB(255, 0, 0, 0), + const ui.Color.fromARGB(255, 0, 0, 255), + ], + ); canvas.drawCircle( ui.Offset(offsetX + 10, offsetY + 10), 10, SurfacePaint() diff --git a/lib/web_ui/test/engine/surface/surface_test.dart b/lib/web_ui/test/engine/surface/surface_test.dart index 29813b72b00cd..fa0cc8c42ba39 100644 --- a/lib/web_ui/test/engine/surface/surface_test.dart +++ b/lib/web_ui/test/engine/surface/surface_test.dart @@ -371,7 +371,7 @@ void testMain() { () { final SceneBuilder builder1 = SceneBuilder(); final Path path = Path(); - path.addPolygon([Offset(50, 0), Offset(100, 80), Offset(20, 40)], true); + path.addPolygon([Offset(50, 0), Offset(100, 80), Offset(20, 40)], true); PersistedPhysicalShape shape = builder1.pushPhysicalShape(path: path, color: Color(0xFF00FF00), elevation: 1) as PersistedPhysicalShape; builder1.build(); diff --git a/lib/web_ui/test/engine/window_test.dart b/lib/web_ui/test/engine/window_test.dart index 2ff153d73221b..4f8b8721d72cc 100644 --- a/lib/web_ui/test/engine/window_test.dart +++ b/lib/web_ui/test/engine/window_test.dart @@ -270,7 +270,7 @@ void testMain() { window.sendPlatformMessage( 'flutter/debug-echo', inputData, - (outputData) { + (ByteData? outputData) { expect(Zone.current, innerZone); completer.complete(); }, @@ -288,7 +288,7 @@ void testMain() { window.sendPlatformMessage( 'flutter/__unknown__channel__', null, - (outputData) { + (ByteData? outputData) { responded = true; expect(outputData, isNull); }, @@ -311,7 +311,7 @@ void testMain() { window.sendPlatformMessage( 'flutter/platform', inputData, - (outputData) { + (ByteData? outputData) { completer.complete(true); }, ); @@ -355,7 +355,7 @@ void testMain() { window.sendPlatformMessage( 'flutter/service_worker', ByteData(0), - (outputData) { }, + (ByteData? outputData) { }, ); }); diff --git a/lib/web_ui/test/golden_tests/engine/canvas_draw_points_test.dart b/lib/web_ui/test/golden_tests/engine/canvas_draw_points_test.dart index 0716bdcd717aa..dcec1ea136b85 100644 --- a/lib/web_ui/test/golden_tests/engine/canvas_draw_points_test.dart +++ b/lib/web_ui/test/golden_tests/engine/canvas_draw_points_test.dart @@ -62,19 +62,19 @@ void testMain() async { test('Should draw points with strokeWidth', () async { final SurfacePaintData nullStrokePaint = SurfacePaintData()..color = Color(0xffff0000); - canvas.drawPoints(PointMode.lines, Float32List.fromList([ + canvas.drawPoints(PointMode.lines, Float32List.fromList([ 30.0, 20.0, 200.0, 20.0]), nullStrokePaint); final SurfacePaintData strokePaint1 = SurfacePaintData() ..strokeWidth = 1.0 ..color = Color(0xff0000ff); - canvas.drawPoints(PointMode.lines, Float32List.fromList([ + canvas.drawPoints(PointMode.lines, Float32List.fromList([ 30.0, 30.0, 200.0, 30.0]), strokePaint1); final SurfacePaintData strokePaint3 = SurfacePaintData() ..strokeWidth = 3.0 ..color = Color(0xff00a000); - canvas.drawPoints(PointMode.lines, Float32List.fromList([ + canvas.drawPoints(PointMode.lines, Float32List.fromList([ 30.0, 40.0, 200.0, 40.0]), strokePaint3); - canvas.drawPoints(PointMode.points, Float32List.fromList([ + canvas.drawPoints(PointMode.points, Float32List.fromList([ 30.0, 50.0, 40.0, 50.0, 50.0, 50.0]), strokePaint3); html.document.body!.append(canvas.rootElement); await matchGoldenFile('canvas_draw_points_stroke.png', region: region); diff --git a/lib/web_ui/test/golden_tests/engine/canvas_golden_test.dart b/lib/web_ui/test/golden_tests/engine/canvas_golden_test.dart index 3cba7c9ffbf8b..fb4f41c7ab5c6 100644 --- a/lib/web_ui/test/golden_tests/engine/canvas_golden_test.dart +++ b/lib/web_ui/test/golden_tests/engine/canvas_golden_test.dart @@ -172,7 +172,7 @@ void testMain() async { canvas.drawParagraph(paragraph, Offset(8.5, 8.5 + innerClip.top)); expect( - canvas.rootElement.querySelectorAll('p').map((e) => e.innerText).toList(), + canvas.rootElement.querySelectorAll('p').map((html.Element e) => e.innerText).toList(), ['Am I blurry?', 'Am I blurry?'], reason: 'Expected to render text using HTML', ); @@ -230,7 +230,7 @@ void testMain() async { canvas.drawParagraph(paragraph, const Offset(180, 50)); expect( - canvas.rootElement.querySelectorAll('p').map((e) => e.text).toList(), + canvas.rootElement.querySelectorAll('p').map((html.Element e) => e.text).toList(), [text], reason: 'Expected to render text using HTML', ); diff --git a/lib/web_ui/test/golden_tests/engine/canvas_image_blend_mode_test.dart b/lib/web_ui/test/golden_tests/engine/canvas_image_blend_mode_test.dart index 3785c48e4134d..752875608dcfb 100644 --- a/lib/web_ui/test/golden_tests/engine/canvas_image_blend_mode_test.dart +++ b/lib/web_ui/test/golden_tests/engine/canvas_image_blend_mode_test.dart @@ -36,14 +36,19 @@ void testMain() async { const Color grey = Color(0xFF808080); const Color black = Color(0xFF000000); - List> modes = [[BlendMode.clear, BlendMode.src, BlendMode.dst, - BlendMode.srcOver, BlendMode.dstOver, BlendMode.srcIn, BlendMode.dstIn, BlendMode.srcOut], - [BlendMode.dstOut, BlendMode.srcATop, BlendMode.dstATop, BlendMode.xor, - BlendMode.plus, BlendMode.modulate, BlendMode.screen, BlendMode.overlay], - [BlendMode.darken, BlendMode.lighten, BlendMode.colorDodge, BlendMode.hardLight, - BlendMode.softLight, BlendMode.difference, BlendMode.exclusion, BlendMode.multiply], - [BlendMode.hue, BlendMode.saturation, BlendMode.color, - BlendMode.luminosity]]; + List> modes = >[ + [BlendMode.clear, BlendMode.src, BlendMode.dst, + BlendMode.srcOver, BlendMode.dstOver, BlendMode.srcIn, BlendMode.dstIn, + BlendMode.srcOut], + [BlendMode.dstOut, BlendMode.srcATop, BlendMode.dstATop, + BlendMode.xor, BlendMode.plus, BlendMode.modulate, BlendMode.screen, + BlendMode.overlay], + [BlendMode.darken, BlendMode.lighten, BlendMode.colorDodge, + BlendMode.hardLight, BlendMode.softLight, BlendMode.difference, + BlendMode.exclusion, BlendMode.multiply], + [BlendMode.hue, BlendMode.saturation, BlendMode.color, + BlendMode.luminosity], + ]; for (int blendGroup = 0; blendGroup < 4; ++blendGroup) { test('Draw image with Group$blendGroup blend modes', () async { diff --git a/lib/web_ui/test/golden_tests/engine/canvas_mask_filter_test.dart b/lib/web_ui/test/golden_tests/engine/canvas_mask_filter_test.dart index ebb657337f6c3..bbe3a13e886ad 100644 --- a/lib/web_ui/test/golden_tests/engine/canvas_mask_filter_test.dart +++ b/lib/web_ui/test/golden_tests/engine/canvas_mask_filter_test.dart @@ -110,7 +110,7 @@ void testMain() async { paint.color = ui.Color(0xFF6500C9); rc.drawRawPoints( ui.PointMode.points, - Float32List.fromList([-10, -10, -10, 10, 10, -10, 10, 10]), + Float32List.fromList([-10, -10, -10, 10, 10, -10, 10, 10]), paint, ); diff --git a/lib/web_ui/test/golden_tests/engine/canvas_paragraph/bidi_test.dart b/lib/web_ui/test/golden_tests/engine/canvas_paragraph/bidi_test.dart index 048c4759c1d7c..604f44390b60c 100644 --- a/lib/web_ui/test/golden_tests/engine/canvas_paragraph/bidi_test.dart +++ b/lib/web_ui/test/golden_tests/engine/canvas_paragraph/bidi_test.dart @@ -52,7 +52,7 @@ void testMain() async { test('basic bidi starting with ltr', () { const Rect bounds = Rect.fromLTWH(0, 0, 340, 600); - final canvas = BitmapCanvas(bounds, RenderStrategy()); + final BitmapCanvas canvas = BitmapCanvas(bounds, RenderStrategy()); const double height = 40; @@ -91,7 +91,7 @@ void testMain() async { test('basic bidi starting with ltr (DOM)', () { const Rect bounds = Rect.fromLTWH(0, 0, 340, 600); - final canvas = DomCanvas(domRenderer.createElement('flt-picture')); + final DomCanvas canvas = DomCanvas(domRenderer.createElement('flt-picture')); const double height = 40; @@ -156,7 +156,7 @@ void testMain() async { test('basic bidi starting with rtl', () { const Rect bounds = Rect.fromLTWH(0, 0, 340, 600); - final canvas = BitmapCanvas(bounds, RenderStrategy()); + final BitmapCanvas canvas = BitmapCanvas(bounds, RenderStrategy()); const double height = 40; @@ -195,7 +195,7 @@ void testMain() async { test('basic bidi starting with rtl (DOM)', () { const Rect bounds = Rect.fromLTWH(0, 0, 340, 600); - final canvas = DomCanvas(domRenderer.createElement('flt-picture')); + final DomCanvas canvas = DomCanvas(domRenderer.createElement('flt-picture')); const double height = 40; @@ -264,7 +264,7 @@ void testMain() async { test('multiline bidi', () { final Rect bounds = Rect.fromLTWH(0, 0, 400, 500); - final canvas = BitmapCanvas(bounds, RenderStrategy()); + final BitmapCanvas canvas = BitmapCanvas(bounds, RenderStrategy()); const double height = 95; @@ -303,7 +303,7 @@ void testMain() async { test('multiline bidi (DOM)', () { const Rect bounds = Rect.fromLTWH(0, 0, 400, 500); - final canvas = DomCanvas(domRenderer.createElement('flt-picture')); + final DomCanvas canvas = DomCanvas(domRenderer.createElement('flt-picture')); const double height = 95; @@ -357,7 +357,7 @@ void testMain() async { // $_rtlWord2 34 ipsum // dolor 56 // ''' - final CanvasParagraph paragraph = rich(paragraphStyle, (builder) { + final CanvasParagraph paragraph = rich(paragraphStyle, (CanvasParagraphBuilder builder) { builder.pushStyle(EngineTextStyle.only(color: blue)); builder.addText('Lorem '); builder.pushStyle(EngineTextStyle.only(color: green)); @@ -378,7 +378,7 @@ void testMain() async { test('multi span bidi', () { const Rect bounds = Rect.fromLTWH(0, 0, 400, 900); - final canvas = BitmapCanvas(bounds, RenderStrategy()); + final BitmapCanvas canvas = BitmapCanvas(bounds, RenderStrategy()); const double height = 95; @@ -417,7 +417,7 @@ void testMain() async { test('multi span bidi (DOM)', () { const Rect bounds = Rect.fromLTWH(0, 0, 400, 900); - final canvas = DomCanvas(domRenderer.createElement('flt-picture')); + final DomCanvas canvas = DomCanvas(domRenderer.createElement('flt-picture')); const double height = 95; @@ -497,7 +497,7 @@ void testMain() async { test('bidi with selection', () { const Rect bounds = Rect.fromLTWH(0, 0, 400, 500); - final canvas = BitmapCanvas(bounds, RenderStrategy()); + final BitmapCanvas canvas = BitmapCanvas(bounds, RenderStrategy()); const double height = 95; @@ -536,7 +536,7 @@ void testMain() async { test('bidi with selection (DOM)', () { const Rect bounds = Rect.fromLTWH(0, 0, 400, 500); - final canvas = DomCanvas(domRenderer.createElement('flt-picture')); + final DomCanvas canvas = DomCanvas(domRenderer.createElement('flt-picture')); const double height = 95; diff --git a/lib/web_ui/test/golden_tests/engine/canvas_paragraph/general_test.dart b/lib/web_ui/test/golden_tests/engine/canvas_paragraph/general_test.dart index 460c67084a550..2460e3e3deda9 100644 --- a/lib/web_ui/test/golden_tests/engine/canvas_paragraph/general_test.dart +++ b/lib/web_ui/test/golden_tests/engine/canvas_paragraph/general_test.dart @@ -26,13 +26,13 @@ void testMain() async { setUpStableTestFonts(); test('paints spans and lines correctly', () { - final canvas = BitmapCanvas(bounds, RenderStrategy()); + final BitmapCanvas canvas = BitmapCanvas(bounds, RenderStrategy()); Offset offset = Offset.zero; CanvasParagraph paragraph; // Single-line multi-span. - paragraph = rich(EngineParagraphStyle(fontFamily: 'Roboto'), (builder) { + paragraph = rich(EngineParagraphStyle(fontFamily: 'Roboto'), (CanvasParagraphBuilder builder) { builder.pushStyle(EngineTextStyle.only(color: blue)); builder.addText('Lorem '); builder.pushStyle(EngineTextStyle.only( @@ -48,7 +48,7 @@ void testMain() async { offset = offset.translate(0, paragraph.height + 10); // Multi-line single-span. - paragraph = rich(EngineParagraphStyle(fontFamily: 'Roboto'), (builder) { + paragraph = rich(EngineParagraphStyle(fontFamily: 'Roboto'), (CanvasParagraphBuilder builder) { builder.addText('Lorem ipsum dolor sit'); }) ..layout(constrain(90.0)); @@ -56,7 +56,7 @@ void testMain() async { offset = offset.translate(0, paragraph.height + 10); // Multi-line multi-span. - paragraph = rich(EngineParagraphStyle(fontFamily: 'Roboto'), (builder) { + paragraph = rich(EngineParagraphStyle(fontFamily: 'Roboto'), (CanvasParagraphBuilder builder) { builder.pushStyle(EngineTextStyle.only(color: blue)); builder.addText('Lorem ipsum '); builder.pushStyle(EngineTextStyle.only(background: Paint()..color = red)); @@ -73,7 +73,7 @@ void testMain() async { }); test('respects alignment', () { - final canvas = BitmapCanvas(bounds, RenderStrategy()); + final BitmapCanvas canvas = BitmapCanvas(bounds, RenderStrategy()); Offset offset = Offset.zero; CanvasParagraph paragraph; @@ -114,7 +114,7 @@ void testMain() async { }); test('respects alignment in DOM mode', () { - final canvas = DomCanvas(domRenderer.createElement('flt-picture')); + final DomCanvas canvas = DomCanvas(domRenderer.createElement('flt-picture')); Offset offset = Offset.zero; CanvasParagraph paragraph; @@ -186,13 +186,13 @@ void testMain() async { } test('alignment and transform', () { - final canvas = BitmapCanvas(bounds, RenderStrategy()); + final BitmapCanvas canvas = BitmapCanvas(bounds, RenderStrategy()); testAlignAndTransform(canvas); return takeScreenshot(canvas, bounds, 'canvas_paragraph_align_transform'); }); test('alignment and transform (DOM)', () { - final canvas = DomCanvas(domRenderer.createElement('flt-picture')); + final DomCanvas canvas = DomCanvas(domRenderer.createElement('flt-picture')); testAlignAndTransform(canvas); return takeScreenshot(canvas, bounds, 'canvas_paragraph_align_transform_dom'); }); @@ -214,14 +214,14 @@ void testMain() async { test('giant paragraph style', () { const Rect bounds = Rect.fromLTWH(0, 0, 300, 200); - final canvas = BitmapCanvas(bounds, RenderStrategy()); + final BitmapCanvas canvas = BitmapCanvas(bounds, RenderStrategy()); testGiantParagraphStyles(canvas); return takeScreenshot(canvas, bounds, 'canvas_paragraph_giant_paragraph_style'); }); test('giant paragraph style (DOM)', () { const Rect bounds = Rect.fromLTWH(0, 0, 300, 200); - final canvas = DomCanvas(domRenderer.createElement('flt-picture')); + final DomCanvas canvas = DomCanvas(domRenderer.createElement('flt-picture')); testGiantParagraphStyles(canvas); return takeScreenshot(canvas, bounds, 'canvas_paragraph_giant_paragraph_style_dom'); }); @@ -233,7 +233,7 @@ void testMain() async { final String oldBodyFontSize = html.document.body!.style.fontSize; html.document.body!.style.fontSize = '100px'; - final canvas = DomCanvas(domRenderer.createElement('flt-picture')); + final DomCanvas canvas = DomCanvas(domRenderer.createElement('flt-picture')); Offset offset = Offset(10.0, 10.0); final CanvasParagraph paragraph = rich( @@ -284,11 +284,11 @@ void testMain() async { }); test('paints spans with varying heights/baselines', () { - final canvas = BitmapCanvas(bounds, RenderStrategy()); + final BitmapCanvas canvas = BitmapCanvas(bounds, RenderStrategy()); final CanvasParagraph paragraph = rich( EngineParagraphStyle(fontFamily: 'Roboto'), - (builder) { + (CanvasParagraphBuilder builder) { builder.pushStyle(EngineTextStyle.only(fontSize: 20.0)); builder.addText('Lorem '); builder.pushStyle(EngineTextStyle.only( @@ -319,11 +319,11 @@ void testMain() async { }); test('respects letter-spacing', () { - final canvas = BitmapCanvas(bounds, RenderStrategy()); + final BitmapCanvas canvas = BitmapCanvas(bounds, RenderStrategy()); final CanvasParagraph paragraph = rich( EngineParagraphStyle(fontFamily: 'Roboto'), - (builder) { + (CanvasParagraphBuilder builder) { builder.pushStyle(EngineTextStyle.only(color: blue)); builder.addText('Lorem '); builder.pushStyle(EngineTextStyle.only(color: green, letterSpacing: 1)); @@ -338,7 +338,7 @@ void testMain() async { }); test('draws text decorations', () { - final canvas = BitmapCanvas(bounds, RenderStrategy()); + final BitmapCanvas canvas = BitmapCanvas(bounds, RenderStrategy()); final List decorationStyles = [ TextDecorationStyle.solid, TextDecorationStyle.double, @@ -349,7 +349,7 @@ void testMain() async { final CanvasParagraph paragraph = rich( EngineParagraphStyle(fontFamily: 'Roboto'), - (builder) { + (CanvasParagraphBuilder builder) { for (TextDecorationStyle decorationStyle in decorationStyles) { builder.pushStyle(EngineTextStyle.only( color: const Color.fromRGBO(50, 50, 255, 1.0), @@ -455,14 +455,14 @@ void testMain() async { test('font features', () { const Rect bounds = Rect.fromLTWH(0, 0, 600, 500); - final canvas = BitmapCanvas(bounds, RenderStrategy()); + final BitmapCanvas canvas = BitmapCanvas(bounds, RenderStrategy()); testFontFeatures(canvas); return takeScreenshot(canvas, bounds, 'canvas_paragraph_font_features'); }); test('font features (DOM)', () { const Rect bounds = Rect.fromLTWH(0, 0, 600, 500); - final canvas = DomCanvas(domRenderer.createElement('flt-picture')); + final DomCanvas canvas = DomCanvas(domRenderer.createElement('flt-picture')); testFontFeatures(canvas); return takeScreenshot(canvas, bounds, 'canvas_paragraph_font_features_dom'); }); @@ -491,14 +491,14 @@ void testMain() async { test('background style', () { const Rect bounds = Rect.fromLTWH(0, 0, 300, 200); - final canvas = BitmapCanvas(bounds, RenderStrategy()); + final BitmapCanvas canvas = BitmapCanvas(bounds, RenderStrategy()); testBackgroundStyle(canvas); return takeScreenshot(canvas, bounds, 'canvas_paragraph_background_style'); }); test('background style (DOM)', () { const Rect bounds = Rect.fromLTWH(0, 0, 300, 200); - final canvas = DomCanvas(domRenderer.createElement('flt-picture')); + final DomCanvas canvas = DomCanvas(domRenderer.createElement('flt-picture')); testBackgroundStyle(canvas); return takeScreenshot(canvas, bounds, 'canvas_paragraph_background_style_dom'); }); diff --git a/lib/web_ui/test/golden_tests/engine/canvas_paragraph/overflow_test.dart b/lib/web_ui/test/golden_tests/engine/canvas_paragraph/overflow_test.dart index ed4c33c7e87bb..1ec3095b7c363 100644 --- a/lib/web_ui/test/golden_tests/engine/canvas_paragraph/overflow_test.dart +++ b/lib/web_ui/test/golden_tests/engine/canvas_paragraph/overflow_test.dart @@ -31,7 +31,7 @@ void testMain() async { paragraph = rich( EngineParagraphStyle(fontFamily: 'Roboto', fontSize: fontSize, ellipsis: '...'), - (builder) { + (CanvasParagraphBuilder builder) { builder.pushStyle(EngineTextStyle.only(color: blue)); builder.addText('Lorem '); builder.pushStyle(EngineTextStyle.only(color: green)); @@ -43,7 +43,7 @@ void testMain() async { paragraph = rich( EngineParagraphStyle(fontFamily: 'Roboto', fontSize: fontSize, ellipsis: '...'), - (builder) { + (CanvasParagraphBuilder builder) { builder.pushStyle(EngineTextStyle.only(color: blue)); builder.addText('Lorem\n'); builder.pushStyle(EngineTextStyle.only(color: green)); @@ -57,7 +57,7 @@ void testMain() async { paragraph = rich( EngineParagraphStyle(fontFamily: 'Roboto', fontSize: fontSize, ellipsis: '...'), - (builder) { + (CanvasParagraphBuilder builder) { builder.pushStyle(EngineTextStyle.only(color: blue)); builder.addText('Lorem\n'); builder.pushStyle(EngineTextStyle.only(color: green)); @@ -87,7 +87,7 @@ void testMain() async { paragraph = rich( EngineParagraphStyle(fontFamily: 'Roboto', fontSize: fontSize, maxLines: 2, ellipsis: '...'), - (builder) { + (CanvasParagraphBuilder builder) { builder.pushStyle(EngineTextStyle.only(color: blue)); builder.addText('Lorem'); builder.pushStyle(EngineTextStyle.only(color: green)); diff --git a/lib/web_ui/test/golden_tests/engine/canvas_paragraph/placeholders_test.dart b/lib/web_ui/test/golden_tests/engine/canvas_paragraph/placeholders_test.dart index e4b417c2bd3b9..6dd40b4b61a65 100644 --- a/lib/web_ui/test/golden_tests/engine/canvas_paragraph/placeholders_test.dart +++ b/lib/web_ui/test/golden_tests/engine/canvas_paragraph/placeholders_test.dart @@ -24,13 +24,13 @@ void testMain() async { setUpStableTestFonts(); test('draws paragraphs with placeholders', () { - final canvas = BitmapCanvas(bounds, RenderStrategy()); + final BitmapCanvas canvas = BitmapCanvas(bounds, RenderStrategy()); Offset offset = Offset.zero; for (PlaceholderAlignment placeholderAlignment in PlaceholderAlignment.values) { final CanvasParagraph paragraph = rich( EngineParagraphStyle(fontFamily: 'Roboto', fontSize: 14.0), - (builder) { + (CanvasParagraphBuilder builder) { builder.pushStyle(TextStyle(color: black)); builder.addText('Lorem ipsum'); builder.addPlaceholder( @@ -58,7 +58,7 @@ void testMain() async { }); test('draws paragraphs with placeholders and text align', () { - final canvas = BitmapCanvas(bounds, RenderStrategy()); + final BitmapCanvas canvas = BitmapCanvas(bounds, RenderStrategy()); const List aligns = [ TextAlign.left, @@ -70,7 +70,7 @@ void testMain() async { for (TextAlign align in aligns) { final CanvasParagraph paragraph = rich( EngineParagraphStyle(fontFamily: 'Roboto', fontSize: 14.0, textAlign: align), - (builder) { + (CanvasParagraphBuilder builder) { builder.pushStyle(TextStyle(color: black)); builder.addText('Lorem'); builder.addPlaceholder(80.0, 50.0, PlaceholderAlignment.bottom); @@ -92,7 +92,7 @@ void testMain() async { }); test('draws paragraphs with placeholders and text align in DOM mode', () { - final canvas = DomCanvas(domRenderer.createElement('flt-picture')); + final DomCanvas canvas = DomCanvas(domRenderer.createElement('flt-picture')); const List aligns = [ TextAlign.left, @@ -104,7 +104,7 @@ void testMain() async { for (TextAlign align in aligns) { final CanvasParagraph paragraph = rich( EngineParagraphStyle(fontFamily: 'Roboto', fontSize: 14.0, textAlign: align), - (builder) { + (CanvasParagraphBuilder builder) { builder.pushStyle(TextStyle(color: black)); builder.addText('Lorem'); builder.addPlaceholder(80.0, 50.0, PlaceholderAlignment.bottom); @@ -127,14 +127,14 @@ void testMain() async { test('draws paragraphs starting or ending with a placeholder', () { const Rect bounds = Rect.fromLTWH(0, 0, 420, 300); - final canvas = BitmapCanvas(bounds, RenderStrategy()); + final BitmapCanvas canvas = BitmapCanvas(bounds, RenderStrategy()); Offset offset = Offset(10, 10); // First paragraph with a placeholder at the beginning. final CanvasParagraph paragraph1 = rich( EngineParagraphStyle(fontFamily: 'Roboto', fontSize: 24.0, textAlign: TextAlign.center), - (builder) { + (CanvasParagraphBuilder builder) { builder.addPlaceholder(80.0, 50.0, PlaceholderAlignment.baseline, baseline: TextBaseline.alphabetic); builder.pushStyle(TextStyle(color: black)); builder.addText(' Lorem ipsum.'); @@ -151,7 +151,7 @@ void testMain() async { // Second paragraph with a placeholder at the end. final CanvasParagraph paragraph2 = rich( EngineParagraphStyle(fontFamily: 'Roboto', fontSize: 24.0, textAlign: TextAlign.center), - (builder) { + (CanvasParagraphBuilder builder) { builder.pushStyle(TextStyle(color: black)); builder.addText('Lorem ipsum '); builder.addPlaceholder(80.0, 50.0, PlaceholderAlignment.baseline, baseline: TextBaseline.alphabetic); @@ -168,7 +168,7 @@ void testMain() async { // Third paragraph with a placeholder alone in the second line. final CanvasParagraph paragraph3 = rich( EngineParagraphStyle(fontFamily: 'Roboto', fontSize: 24.0, textAlign: TextAlign.center), - (builder) { + (CanvasParagraphBuilder builder) { builder.pushStyle(TextStyle(color: black)); builder.addText('Lorem ipsum '); builder.addPlaceholder(80.0, 50.0, PlaceholderAlignment.baseline, baseline: TextBaseline.alphabetic); diff --git a/lib/web_ui/test/golden_tests/engine/canvas_paragraph/shadows_test.dart b/lib/web_ui/test/golden_tests/engine/canvas_paragraph/shadows_test.dart index 26d79c757b0c5..5d62888a7c08e 100644 --- a/lib/web_ui/test/golden_tests/engine/canvas_paragraph/shadows_test.dart +++ b/lib/web_ui/test/golden_tests/engine/canvas_paragraph/shadows_test.dart @@ -20,15 +20,15 @@ void testMain() async { setUpStableTestFonts(); test('paints multiple shadows', () { - final canvas = BitmapCanvas(bounds, RenderStrategy()); + final BitmapCanvas canvas = BitmapCanvas(bounds, RenderStrategy()); final CanvasParagraph paragraph = rich( EngineParagraphStyle(fontFamily: 'Roboto'), - (builder) { + (CanvasParagraphBuilder builder) { builder.pushStyle(EngineTextStyle.only( fontSize: 32.0, color: blue, - shadows: [ + shadows: [ Shadow(color: red, blurRadius:2.0, offset: Offset(4.0, 2.0)), Shadow(color: green, blurRadius: 3.0), ], @@ -37,7 +37,7 @@ void testMain() async { builder.pushStyle(EngineTextStyle.only( color: green, background: Paint()..color = yellow, - shadows: [ + shadows: [ Shadow(color: black, blurRadius: 10.0), ], )); diff --git a/lib/web_ui/test/golden_tests/engine/canvas_stroke_joins_golden_test.dart b/lib/web_ui/test/golden_tests/engine/canvas_stroke_joins_golden_test.dart index faf6c0acd53d1..5e8817df38476 100644 --- a/lib/web_ui/test/golden_tests/engine/canvas_stroke_joins_golden_test.dart +++ b/lib/web_ui/test/golden_tests/engine/canvas_stroke_joins_golden_test.dart @@ -48,13 +48,13 @@ void paintStrokeJoins(BitmapCanvas canvas) { Offset mid = Offset(120, 10); Offset end = Offset(120, 20); - var strokeCaps = [StrokeCap.butt, StrokeCap.round, StrokeCap.square]; + List strokeCaps = [StrokeCap.butt, StrokeCap.round, StrokeCap.square]; for (StrokeCap cap in strokeCaps) { - var joints = [StrokeJoin.miter, StrokeJoin.bevel, StrokeJoin.round]; - var colors = [Color(0xFFF44336), Color(0xFF4CAF50), Color(0xFF2196F3)]; // red, green, blue + List joints = [StrokeJoin.miter, StrokeJoin.bevel, StrokeJoin.round]; + List colors = [Color(0xFFF44336), Color(0xFF4CAF50), Color(0xFF2196F3)]; // red, green, blue for (int i = 0; i < joints.length; i++) { - var join = joints[i]; - var color = colors[i % colors.length]; + StrokeJoin join = joints[i]; + Color color = colors[i % colors.length]; Path path = new Path(); path.moveTo(start.dx, start.dy); diff --git a/lib/web_ui/test/golden_tests/engine/compositing_golden_test.dart b/lib/web_ui/test/golden_tests/engine/compositing_golden_test.dart index c4bd067c5e4c9..db414ce8dc1e0 100644 --- a/lib/web_ui/test/golden_tests/engine/compositing_golden_test.dart +++ b/lib/web_ui/test/golden_tests/engine/compositing_golden_test.dart @@ -871,7 +871,7 @@ void _testCullRectComputation() { expect( sceneElement .querySelectorAll('p') - .map((e) => e.innerText) + .map((html.Element e) => e.innerText) .toList(), ['Am I blurry?', 'Am I blurry?'], reason: 'Expected to render text using HTML', diff --git a/lib/web_ui/test/golden_tests/engine/draw_vertices_golden_test.dart b/lib/web_ui/test/golden_tests/engine/draw_vertices_golden_test.dart index 273d068ed1489..efe82331c8bee 100644 --- a/lib/web_ui/test/golden_tests/engine/draw_vertices_golden_test.dart +++ b/lib/web_ui/test/golden_tests/engine/draw_vertices_golden_test.dart @@ -73,7 +73,7 @@ void testMain() async { () async { final Vertices vertices = Vertices.raw( VertexMode.triangles, - Float32List.fromList([ + Float32List.fromList([ 20.0, 20.0, 220.0, @@ -111,7 +111,7 @@ void testMain() async { ]); final Vertices vertices = Vertices.raw( VertexMode.triangles, - Float32List.fromList([ + Float32List.fromList([ 20.0, 20.0, 220.0, @@ -150,7 +150,7 @@ void testMain() async { ]); final Vertices vertices = Vertices.raw( VertexMode.triangles, - Float32List.fromList([ + Float32List.fromList([ 20.0, 20.0, 220.0, @@ -176,7 +176,7 @@ void testMain() async { test('Should draw hairline triangleFan.', () async { final Vertices vertices = Vertices.raw( VertexMode.triangleFan, - Float32List.fromList([ + Float32List.fromList([ 150.0, 150.0, 20.0, @@ -198,7 +198,7 @@ void testMain() async { test('Should draw hairline triangleStrip.', () async { final Vertices vertices = Vertices.raw( VertexMode.triangleStrip, - Float32List.fromList([ + Float32List.fromList([ 20.0, 20.0, 220.0, @@ -227,7 +227,7 @@ void testMain() async { ]); final Vertices vertices = Vertices.raw( VertexMode.triangles, - Float32List.fromList([ + Float32List.fromList([ 150.0, 150.0, 20.0, @@ -257,7 +257,7 @@ void testMain() async { final Vertices vertices = Vertices.raw( VertexMode.triangles, - Float32List.fromList([ + Float32List.fromList([ 210.0, 150.0, 30.0, @@ -289,7 +289,7 @@ void testMain() async { ]); final Vertices vertices = Vertices.raw( VertexMode.triangleFan, - Float32List.fromList([ + Float32List.fromList([ 150.0, 150.0, 20.0, @@ -320,7 +320,7 @@ void testMain() async { ]); final Vertices vertices = Vertices.raw( VertexMode.triangleStrip, - Float32List.fromList([ + Float32List.fromList([ 20.0, 20.0, 220.0, @@ -347,7 +347,7 @@ void testMain() async { final Vertices vertices = Vertices.raw( VertexMode.triangles, - Float32List.fromList([ + Float32List.fromList([ 210.0, 150.0, 0.0, @@ -402,8 +402,8 @@ Future createTestImage({int width = 50, int height = 40}) { ctx.fillRect(2 * width / 3, 0, width / 3, height); ctx.fill(); html.ImageElement imageElement = html.ImageElement(); - Completer completer = Completer(); - imageElement.onLoad.listen((event) { + Completer completer = Completer(); + imageElement.onLoad.listen((html.Event event) { completer.complete(HtmlImage(imageElement, width, height)); }); imageElement.src = js_util.callMethod(canvas, 'toDataURL', []); diff --git a/lib/web_ui/test/golden_tests/engine/linear_gradient_golden_test.dart b/lib/web_ui/test/golden_tests/engine/linear_gradient_golden_test.dart index bec49b4b11faa..aab868e092270 100644 --- a/lib/web_ui/test/golden_tests/engine/linear_gradient_golden_test.dart +++ b/lib/web_ui/test/golden_tests/engine/linear_gradient_golden_test.dart @@ -33,7 +33,7 @@ void testMain() async { final SurfacePaint paint = SurfacePaint()..shader = Gradient.linear( Offset(shaderRect.left, shaderRect.top), Offset(shaderRect.right, shaderRect.bottom), - [Color(0xFFcfdfd2), Color(0xFF042a85)]); + [Color(0xFFcfdfd2), Color(0xFF042a85)]); rc.drawRect(shaderRect, paint); expect(rc.renderStrategy.hasArbitraryPaint, isTrue); await canvasScreenshot(rc, 'linear_gradient_rect', @@ -44,7 +44,7 @@ void testMain() async { test('Should draw linear gradient with transform.', () async { final RecordingCanvas rc = RecordingCanvas(const Rect.fromLTRB(0, 0, 500, 500)); - List angles = [0.0, 90.0, 180.0]; + List angles = [0.0, 90.0, 180.0]; double yOffset = 0; for (double angle in angles) { final Rect shaderRect = Rect.fromLTWH(50, 50 + yOffset, 100, 100); @@ -59,7 +59,7 @@ void testMain() async { ..shader = Gradient.linear( Offset(shaderRect.left, shaderRect.top), Offset(shaderRect.right, shaderRect.bottom), - [Color(0xFFFF0000), Color(0xFF042a85)], + [Color(0xFFFF0000), Color(0xFF042a85)], null, TileMode.clamp, matrix.toFloat64()); @@ -82,7 +82,7 @@ void testMain() async { final SurfacePaint paint = SurfacePaint()..shader = Gradient.linear( Offset(shaderRect.left, shaderRect.top), Offset(shaderRect.right, shaderRect.bottom), - [Color(0xFFcfdfd2), Color(0xFF042a85)]); + [Color(0xFFcfdfd2), Color(0xFF042a85)]); rc.drawRRect(RRect.fromRectAndRadius(shaderRect, Radius.circular(16)), paint); expect(rc.renderStrategy.hasArbitraryPaint, isTrue); await canvasScreenshot(rc, 'linear_gradient_rounded_rect', @@ -93,7 +93,7 @@ void testMain() async { test('Should draw tiled repeated linear gradient with transform.', () async { final RecordingCanvas rc = RecordingCanvas(const Rect.fromLTRB(0, 0, 500, 500)); - List angles = [0.0, 30.0, 210.0]; + List angles = [0.0, 30.0, 210.0]; double yOffset = 0; for (double angle in angles) { final Rect shaderRect = Rect.fromLTWH(50, 50 + yOffset, 100, 100); @@ -101,7 +101,7 @@ void testMain() async { ..shader = Gradient.linear( Offset(shaderRect.left, shaderRect.top), Offset(shaderRect.left + shaderRect.width / 2, shaderRect.top), - [Color(0xFFFF0000), Color(0xFF042a85)], + [Color(0xFFFF0000), Color(0xFF042a85)], null, TileMode.repeated, Matrix4 @@ -120,7 +120,7 @@ void testMain() async { test('Should draw tiled mirrored linear gradient with transform.', () async { final RecordingCanvas rc = RecordingCanvas(const Rect.fromLTRB(0, 0, 500, 500)); - List angles = [0.0, 30.0, 210.0]; + List angles = [0.0, 30.0, 210.0]; double yOffset = 0; for (double angle in angles) { final Rect shaderRect = Rect.fromLTWH(50, 50 + yOffset, 100, 100); @@ -128,7 +128,7 @@ void testMain() async { ..shader = Gradient.linear( Offset(shaderRect.left, shaderRect.top), Offset(shaderRect.left + shaderRect.width / 2, shaderRect.top), - [Color(0xFFFF0000), Color(0xFF042a85)], + [Color(0xFFFF0000), Color(0xFF042a85)], null, TileMode.mirror, Matrix4 diff --git a/lib/web_ui/test/golden_tests/engine/radial_gradient_golden_test.dart b/lib/web_ui/test/golden_tests/engine/radial_gradient_golden_test.dart index e1ae4a9617143..a1a4e261f0e8b 100644 --- a/lib/web_ui/test/golden_tests/engine/radial_gradient_golden_test.dart +++ b/lib/web_ui/test/golden_tests/engine/radial_gradient_golden_test.dart @@ -44,7 +44,7 @@ void testMain() async { Offset((shaderRect.left + shaderRect.right) / 2, (shaderRect.top + shaderRect.bottom) / 2), shaderRect.width / 2, - [ + [ const Color.fromARGB(255, 0, 0, 0), const Color.fromARGB(255, 0, 0, 255) ]), @@ -55,32 +55,38 @@ void testMain() async { test('Should draw right bottom centered radial gradient.', () async { Rect shaderRect = const Rect.fromLTRB(50, 50, 300, 300); await _testGradient( - 'radial_gradient_right_bottom', - Gradient.radial( - Offset(shaderRect.right, shaderRect.bottom), shaderRect.width / 2, [ + 'radial_gradient_right_bottom', + Gradient.radial( + Offset(shaderRect.right, shaderRect.bottom), + shaderRect.width / 2, + [ const Color.fromARGB(255, 0, 0, 0), const Color.fromARGB(255, 0, 0, 255) - ]), - shaderRect: shaderRect, - maxDiffRatePercent: 0.3); + ], + ), + shaderRect: shaderRect, + maxDiffRatePercent: 0.3, + ); }); test('Should draw with radial gradient with TileMode.clamp.', () async { Rect shaderRect = const Rect.fromLTRB(50, 50, 100, 100); await _testGradient( - 'radial_gradient_tilemode_clamp', - Gradient.radial( - Offset((shaderRect.left + shaderRect.right) / 2, - (shaderRect.top + shaderRect.bottom) / 2), - shaderRect.width / 2, - [ - const Color.fromARGB(255, 0, 0, 0), - const Color.fromARGB(255, 0, 0, 255) - ], - [0.0, 1.0], - TileMode.clamp), - shaderRect: shaderRect, - maxDiffRatePercent: 0.2); + 'radial_gradient_tilemode_clamp', + Gradient.radial( + Offset((shaderRect.left + shaderRect.right) / 2, + (shaderRect.top + shaderRect.bottom) / 2), + shaderRect.width / 2, + [ + const Color.fromARGB(255, 0, 0, 0), + const Color.fromARGB(255, 0, 0, 255) + ], + [0.0, 1.0], + TileMode.clamp, + ), + shaderRect: shaderRect, + maxDiffRatePercent: 0.2, + ); }); const List colors = [ diff --git a/lib/web_ui/test/keyboard_converter_test.dart b/lib/web_ui/test/keyboard_converter_test.dart index 53595894bd067..f7127ab29b5cc 100644 --- a/lib/web_ui/test/keyboard_converter_test.dart +++ b/lib/web_ui/test/keyboard_converter_test.dart @@ -51,7 +51,7 @@ void testMain() { return key.type == ui.KeyEventType.down; }); bool preventedDefault = false; - final onPreventDefault = () { preventedDefault = true; }; + final ui.VoidCallback onPreventDefault = () { preventedDefault = true; }; converter.handleEvent(keyDownEvent('KeyA', 'a') ..timeStamp = 1 @@ -115,7 +115,7 @@ void testMain() { return key.type == ui.KeyEventType.down; }); bool preventedDefault = false; - final onPreventDefault = () { preventedDefault = true; }; + final ui.VoidCallback onPreventDefault = () { preventedDefault = true; }; converter.handleEvent(keyDownEvent('ShiftLeft', 'Shift', kShift, kLocationLeft) ..onPreventDefault = onPreventDefault @@ -356,7 +356,7 @@ void testMain() { return true; }); bool preventedDefault = false; - final onPreventDefault = () { preventedDefault = true; }; + final ui.VoidCallback onPreventDefault = () { preventedDefault = true; }; converter.handleEvent(keyDownEvent('ShiftLeft', 'Shift', kShift, kLocationLeft) ..onPreventDefault = onPreventDefault @@ -392,7 +392,7 @@ void testMain() { return true; }); bool preventedDefault = false; - final onPreventDefault = () { preventedDefault = true; }; + final ui.VoidCallback onPreventDefault = () { preventedDefault = true; }; // A KeyDown of ShiftRight is missed due to loss of focus. converter.handleEvent(keyUpEvent('ShiftRight', 'Shift', 0, kLocationRight) @@ -447,7 +447,7 @@ void testMain() { return true; }, onMacOs: true); bool preventedDefault = false; - final onPreventDefault = () { preventedDefault = true; }; + final ui.VoidCallback onPreventDefault = () { preventedDefault = true; }; // A KeyDown of ShiftRight is missed due to loss of focus. converter.handleEvent(keyDownEvent('CapsLock', 'CapsLock') @@ -886,10 +886,10 @@ class MockKeyboardEvent implements FlutterHtmlKeyboardEvent { } // Flags used for the `modifiers` argument of `key***Event` functions. -const kAlt = 0x1; -const kCtrl = 0x2; -const kShift = 0x4; -const kMeta = 0x8; +const int kAlt = 0x1; +const int kCtrl = 0x2; +const int kShift = 0x4; +const int kMeta = 0x8; // Utility functions to make code more concise. // @@ -935,9 +935,9 @@ MockKeyboardEvent keyRepeatedDownEvent(String code, String key, [int modifiers = } // Flags used for the `activeLocks` argument of expectKeyData. -const kCapsLock = 0x1; -const kNumlLock = 0x2; -const kScrollLock = 0x4; +const int kCapsLock = 0x1; +const int kNumlLock = 0x2; +const int kScrollLock = 0x4; void expectKeyData( ui.KeyData target, { diff --git a/lib/web_ui/test/text/canvas_paragraph_test.dart b/lib/web_ui/test/text/canvas_paragraph_test.dart index 1dd9df7c8f0fb..c53d0081e11f9 100644 --- a/lib/web_ui/test/text/canvas_paragraph_test.dart +++ b/lib/web_ui/test/text/canvas_paragraph_test.dart @@ -40,7 +40,7 @@ void testMain() async { group('$CanvasParagraph.getBoxesForRange', () { test('return empty list for invalid ranges', () { - final CanvasParagraph paragraph = rich(ahemStyle, (builder) { + final CanvasParagraph paragraph = rich(ahemStyle, (CanvasParagraphBuilder builder) { builder.addText('Lorem ipsum'); }) ..layout(constrain(double.infinity)); @@ -53,7 +53,7 @@ void testMain() async { }); test('handles single-line multi-span paragraphs', () { - final CanvasParagraph paragraph = rich(ahemStyle, (builder) { + final CanvasParagraph paragraph = rich(ahemStyle, (CanvasParagraphBuilder builder) { builder.pushStyle(EngineTextStyle.only(color: blue)); builder.addText('Lorem '); builder.pushStyle(EngineTextStyle.only(color: green)); @@ -147,7 +147,7 @@ void testMain() async { }); test('handles multi-line single-span paragraphs', () { - final CanvasParagraph paragraph = rich(ahemStyle, (builder) { + final CanvasParagraph paragraph = rich(ahemStyle, (CanvasParagraphBuilder builder) { builder.addText('Lorem ipsum dolor sit'); }) ..layout(constrain(90.0)); @@ -219,7 +219,7 @@ void testMain() async { }); test('handles multi-line multi-span paragraphs', () { - final CanvasParagraph paragraph = rich(ahemStyle, (builder) { + final CanvasParagraph paragraph = rich(ahemStyle, (CanvasParagraphBuilder builder) { builder.pushStyle(EngineTextStyle.only(color: blue)); builder.addText('Lorem ipsum '); builder.pushStyle(EngineTextStyle.only(color: green)); @@ -309,7 +309,7 @@ void testMain() async { }); test('handles spans with varying heights/baselines', () { - final CanvasParagraph paragraph = rich(ahemStyle, (builder) { + final CanvasParagraph paragraph = rich(ahemStyle, (CanvasParagraphBuilder builder) { builder.pushStyle(EngineTextStyle.only(fontSize: 20.0)); // width = 20.0 * 6 = 120.0 // baseline = 20.0 * 80% = 16.0 @@ -380,7 +380,7 @@ void testMain() async { group('$CanvasParagraph.getPositionForOffset', () { test('handles single-line multi-span paragraphs', () { - final CanvasParagraph paragraph = rich(ahemStyle, (builder) { + final CanvasParagraph paragraph = rich(ahemStyle, (CanvasParagraphBuilder builder) { builder.pushStyle(EngineTextStyle.only(color: blue)); builder.addText('Lorem '); builder.pushStyle(EngineTextStyle.only(color: green)); @@ -448,7 +448,7 @@ void testMain() async { }); test('handles multi-line single-span paragraphs', () { - final CanvasParagraph paragraph = rich(ahemStyle, (builder) { + final CanvasParagraph paragraph = rich(ahemStyle, (CanvasParagraphBuilder builder) { builder.addText('Lorem ipsum dolor sit'); }) ..layout(constrain(90.0)); @@ -543,7 +543,7 @@ void testMain() async { }); test('handles multi-line multi-span paragraphs', () { - final CanvasParagraph paragraph = rich(ahemStyle, (builder) { + final CanvasParagraph paragraph = rich(ahemStyle, (CanvasParagraphBuilder builder) { builder.pushStyle(EngineTextStyle.only(color: blue)); builder.addText('Lorem ipsum '); builder.pushStyle(EngineTextStyle.only(color: green)); @@ -635,7 +635,7 @@ void testMain() async { group('$CanvasParagraph.getLineBoundary', () { test('single-line', () { - final CanvasParagraph paragraph = rich(ahemStyle, (builder) { + final CanvasParagraph paragraph = rich(ahemStyle, (CanvasParagraphBuilder builder) { builder.addText('One single line'); }) ..layout(constrain(400.0)); @@ -651,7 +651,7 @@ void testMain() async { }); test('multi-line', () { - final CanvasParagraph paragraph = rich(ahemStyle, (builder) { + final CanvasParagraph paragraph = rich(ahemStyle, (CanvasParagraphBuilder builder) { builder.addText('First line\n'); builder.addText('Second line\n'); builder.addText('Third line'); diff --git a/lib/web_ui/test/text/font_loading_test.dart b/lib/web_ui/test/text/font_loading_test.dart index 4247fcc4391fd..2b1f6fd13fab0 100644 --- a/lib/web_ui/test/text/font_loading_test.dart +++ b/lib/web_ui/test/text/font_loading_test.dart @@ -93,7 +93,7 @@ void testMain() async { window.onPlatformMessage = (String name, ByteData? data, ui.PlatformMessageResponseCallback? callback) { actualName = name; - final buffer = data!.buffer; + final ByteBuffer buffer = data!.buffer; final Uint8List list = buffer.asUint8List(data.offsetInBytes, data.lengthInBytes); message = utf8.decode(list); @@ -103,7 +103,7 @@ void testMain() async { responseType: 'arraybuffer'); await ui.loadFontFromList(Uint8List.view(response.response), fontFamily: 'Blehm'); - final Completer completer = Completer(); + final Completer completer = Completer(); html.window.requestAnimationFrame( (_) { completer.complete(); } ); await(completer.future); window.onPlatformMessage = oldHandler; diff --git a/lib/web_ui/test/text/layout_service_plain_test.dart b/lib/web_ui/test/text/layout_service_plain_test.dart index b7eddcdb19aae..2b6f63b2b1bbc 100644 --- a/lib/web_ui/test/text/layout_service_plain_test.dart +++ b/lib/web_ui/test/text/layout_service_plain_test.dart @@ -59,7 +59,7 @@ void testMain() async { expect(paragraph.maxIntrinsicWidth, 60); expect(paragraph.minIntrinsicWidth, 30); expect(paragraph.height, 10); - expectLines(paragraph, [ + expectLines(paragraph, [ l(' abc', 0, 6, hardBreak: true, width: 60.0), ]); @@ -68,7 +68,7 @@ void testMain() async { expect(paragraph.maxIntrinsicWidth, 60); expect(paragraph.minIntrinsicWidth, 30); expect(paragraph.height, 10); - expectLines(paragraph, [ + expectLines(paragraph, [ l('abc ', 0, 6, hardBreak: true, width: 30.0), ]); @@ -78,7 +78,7 @@ void testMain() async { expect(paragraph.maxIntrinsicWidth, 100); expect(paragraph.minIntrinsicWidth, 20); expect(paragraph.height, 10); - expectLines(paragraph, [ + expectLines(paragraph, [ l(' ab c ', 0, 10, hardBreak: true, width: 80.0, left: 0.0), ]); @@ -87,7 +87,7 @@ void testMain() async { expect(paragraph.maxIntrinsicWidth, 10); expect(paragraph.minIntrinsicWidth, 0); expect(paragraph.height, 10); - expectLines(paragraph, [ + expectLines(paragraph, [ l(' ', 0, 1, hardBreak: true, width: 0.0, left: 0.0), ]); @@ -96,7 +96,7 @@ void testMain() async { expect(paragraph.maxIntrinsicWidth, 50); expect(paragraph.minIntrinsicWidth, 0); expect(paragraph.height, 10); - expectLines(paragraph, [ + expectLines(paragraph, [ l(' ', 0, 5, hardBreak: true, width: 0.0, left: 0.0), ]); }); @@ -111,7 +111,7 @@ void testMain() async { expect(paragraph.minIntrinsicWidth, 50); expect(paragraph.width, 50); expect(paragraph.height, 10); - expectLines(paragraph, [ + expectLines(paragraph, [ l('12345', 0, 5, hardBreak: true, width: 50.0, left: 0.0, height: 10.0, baseline: 8.0), ]); }); @@ -124,7 +124,7 @@ void testMain() async { expect(paragraph.minIntrinsicWidth, 30); expect(paragraph.width, 70); expect(paragraph.height, 20); - expectLines(paragraph, [ + expectLines(paragraph, [ l('foo bar ', 0, 8, hardBreak: false, width: 70.0, left: 0.0, height: 10.0, baseline: 8.0), l('baz', 8, 11, hardBreak: true, width: 30.0, left: 0.0, height: 10.0, baseline: 18.0), ]); @@ -140,7 +140,7 @@ void testMain() async { expect(paragraph.minIntrinsicWidth, 100); expect(paragraph.width, 50); expect(paragraph.height, 20); - expectLines(paragraph, [ + expectLines(paragraph, [ l('12345', 0, 5, hardBreak: false, width: 50.0, left: 0.0, height: 10.0, baseline: 8.0), l('67890', 5, 10, hardBreak: true, width: 50.0, left: 0.0, height: 10.0, baseline: 18.0), ]); @@ -152,7 +152,7 @@ void testMain() async { expect(paragraph.minIntrinsicWidth, 110); expect(paragraph.width, 50); expect(paragraph.height, 30); - expectLines(paragraph, [ + expectLines(paragraph, [ l('abcde', 0, 5, hardBreak: false, width: 50.0, left: 0.0, height: 10.0, baseline: 8.0), l('fghij', 5, 10, hardBreak: false, width: 50.0, left: 0.0, height: 10.0, baseline: 18.0), l('k lm', 10, 14, hardBreak: true, width: 40.0, left: 0.0, height: 10.0, baseline: 28.0), @@ -165,7 +165,7 @@ void testMain() async { expect(paragraph.minIntrinsicWidth, 60); expect(paragraph.width, 60); expect(paragraph.height, 20); - expectLines(paragraph, [ + expectLines(paragraph, [ l('abcdef ', 0, 7, hardBreak: false, width: 60.0, left: 0.0, height: 10.0, baseline: 8.0), l('gh', 7, 9, hardBreak: true, width: 20.0, left: 0.0, height: 10.0, baseline: 18.0), ]); @@ -178,7 +178,7 @@ void testMain() async { expect(paragraph.minIntrinsicWidth, 20); expect(paragraph.width, 8); expect(paragraph.height, 20); - expectLines(paragraph, [ + expectLines(paragraph, [ l('A', 0, 1, hardBreak: false, width: 10.0, left: 0.0, height: 10.0, baseline: 8.0), l('A', 1, 2, hardBreak: true, width: 10.0, left: 0.0, height: 10.0, baseline: 18.0), ]); @@ -190,7 +190,7 @@ void testMain() async { expect(paragraph.minIntrinsicWidth, 20); expect(paragraph.width, 8); expect(paragraph.height, 30); - expectLines(paragraph, [ + expectLines(paragraph, [ l('A', 0, 1, hardBreak: false, width: 10.0, left: 0.0, height: 10.0, baseline: 8.0), l('A', 1, 3, hardBreak: true, width: 10.0, left: 0.0, height: 10.0, baseline: 18.0), l('A', 3, 4, hardBreak: true, width: 10.0, left: 0.0, height: 10.0, baseline: 28.0), @@ -203,7 +203,7 @@ void testMain() async { expect(paragraph.minIntrinsicWidth, 30); expect(paragraph.width, 8); expect(paragraph.height, 40); - expectLines(paragraph, [ + expectLines(paragraph, [ l('A', 0, 1, hardBreak: false, width: 10.0, left: 0.0, height: 10.0, baseline: 8.0), l('A', 1, 2, hardBreak: false, width: 10.0, left: 0.0, height: 10.0, baseline: 18.0), l('A', 2, 4, hardBreak: true, width: 10.0, left: 0.0, height: 10.0, baseline: 28.0), @@ -220,7 +220,7 @@ void testMain() async { expect(paragraph.minIntrinsicWidth, 20); expect(paragraph.width, 50); expect(paragraph.height, 20); - expectLines(paragraph, [ + expectLines(paragraph, [ l('12', 0, 3, hardBreak: true, width: 20.0, left: 0.0), l('34', 3, 5, hardBreak: true, width: 20.0, left: 0.0), ]); @@ -234,7 +234,7 @@ void testMain() async { expect(paragraph.maxIntrinsicWidth, 40); expect(paragraph.minIntrinsicWidth, 40); expect(paragraph.height, 30); - expectLines(paragraph, [ + expectLines(paragraph, [ l('', 0, 1, hardBreak: true, width: 0.0, left: 0.0), l('', 1, 2, hardBreak: true, width: 0.0, left: 0.0), l('1234', 2, 6, hardBreak: true, width: 40.0, left: 0.0), @@ -245,7 +245,7 @@ void testMain() async { expect(paragraph.maxIntrinsicWidth, 30); expect(paragraph.minIntrinsicWidth, 30); expect(paragraph.height, 30); - expectLines(paragraph, [ + expectLines(paragraph, [ l('12', 0, 3, hardBreak: true, width: 20.0, left: 0.0), l('', 3, 4, hardBreak: true, width: 0.0, left: 0.0), l('345', 4, 7, hardBreak: true, width: 30.0, left: 0.0), @@ -256,7 +256,7 @@ void testMain() async { expect(paragraph.maxIntrinsicWidth, 40); expect(paragraph.minIntrinsicWidth, 40); expect(paragraph.height, 30); - expectLines(paragraph, [ + expectLines(paragraph, [ l('1234', 0, 5, hardBreak: true, width: 40.0, left: 0.0), l('', 5, 6, hardBreak: true, width: 0.0, left: 0.0), l('', 6, 6, hardBreak: true, width: 0.0, left: 0.0), @@ -273,7 +273,7 @@ void testMain() async { expect(paragraph.minIntrinsicWidth, 30); expect(paragraph.width, double.infinity); expect(paragraph.height, 20); - expectLines(paragraph, [ + expectLines(paragraph, [ l('123', 0, 4, hardBreak: true, width: 30.0, left: 0.0), l('456 789', 4, 11, hardBreak: true, width: 70.0, left: 0.0), ]); @@ -310,7 +310,7 @@ void testMain() async { // Simple case. paragraph = plain(ahemStyle, 'abc de fghi')..layout(constrain(50.0)); expect(paragraph.minIntrinsicWidth, 40); - expectLines(paragraph, [ + expectLines(paragraph, [ l('abc ', 0, 4, hardBreak: false, width: 30.0, left: 0.0), l('de ', 4, 7, hardBreak: false, width: 20.0, left: 0.0), l('fghi', 7, 11, hardBreak: true, width: 40.0, left: 0.0), @@ -319,7 +319,7 @@ void testMain() async { // With new lines. paragraph = plain(ahemStyle, 'abcd\nef\nghi')..layout(constrain(50.0)); expect(paragraph.minIntrinsicWidth, 40); - expectLines(paragraph, [ + expectLines(paragraph, [ l('abcd', 0, 5, hardBreak: true, width: 40.0, left: 0.0), l('ef', 5, 8, hardBreak: true, width: 20.0, left: 0.0), l('ghi', 8, 11, hardBreak: true, width: 30.0, left: 0.0), @@ -328,7 +328,7 @@ void testMain() async { // With trailing whitespace. paragraph = plain(ahemStyle, 'abcd efg')..layout(constrain(50.0)); expect(paragraph.minIntrinsicWidth, 40); - expectLines(paragraph, [ + expectLines(paragraph, [ l('abcd ', 0, 10, hardBreak: false, width: 40.0, left: 0.0), l('efg', 10, 13, hardBreak: true, width: 30.0, left: 0.0), ]); @@ -336,7 +336,7 @@ void testMain() async { // With trailing whitespace and new lines. paragraph = plain(ahemStyle, 'abc \ndefg')..layout(constrain(50.0)); expect(paragraph.minIntrinsicWidth, 40); - expectLines(paragraph, [ + expectLines(paragraph, [ l('abc ', 0, 8, hardBreak: true, width: 30.0, left: 0.0), l('defg', 8, 12, hardBreak: true, width: 40.0, left: 0.0), ]); @@ -344,7 +344,7 @@ void testMain() async { // Very long text. paragraph = plain(ahemStyle, 'AAAAAAAAAAAA')..layout(constrain(50.0)); expect(paragraph.minIntrinsicWidth, 120); - expectLines(paragraph, [ + expectLines(paragraph, [ l('AAAAA', 0, 5, hardBreak: false, width: 50.0, left: 0.0), l('AAAAA', 5, 10, hardBreak: false, width: 50.0, left: 0.0), l('AA', 10, 12, hardBreak: true, width: 20.0, left: 0.0), @@ -357,7 +357,7 @@ void testMain() async { // Simple case. paragraph = plain(ahemStyle, 'abc de fghi')..layout(constrain(50.0)); expect(paragraph.maxIntrinsicWidth, 110); - expectLines(paragraph, [ + expectLines(paragraph, [ l('abc ', 0, 4, hardBreak: false, width: 30.0, left: 0.0), l('de ', 4, 7, hardBreak: false, width: 20.0, left: 0.0), l('fghi', 7, 11, hardBreak: true, width: 40.0, left: 0.0), @@ -366,7 +366,7 @@ void testMain() async { // With new lines. paragraph = plain(ahemStyle, 'abcd\nef\nghi')..layout(constrain(50.0)); expect(paragraph.maxIntrinsicWidth, 40); - expectLines(paragraph, [ + expectLines(paragraph, [ l('abcd', 0, 5, hardBreak: true, width: 40.0, left: 0.0), l('ef', 5, 8, hardBreak: true, width: 20.0, left: 0.0), l('ghi', 8, 11, hardBreak: true, width: 30.0, left: 0.0), @@ -375,7 +375,7 @@ void testMain() async { // With long whitespace. paragraph = plain(ahemStyle, 'abcd efg')..layout(constrain(50.0)); expect(paragraph.maxIntrinsicWidth, 100); - expectLines(paragraph, [ + expectLines(paragraph, [ l('abcd ', 0, 7, hardBreak: false, width: 40.0, left: 0.0), l('efg', 7, 10, hardBreak: true, width: 30.0, left: 0.0), ]); @@ -383,7 +383,7 @@ void testMain() async { // With trailing whitespace. paragraph = plain(ahemStyle, 'abc def ')..layout(constrain(50.0)); expect(paragraph.maxIntrinsicWidth, 100); - expectLines(paragraph, [ + expectLines(paragraph, [ l('abc ', 0, 4, hardBreak: false, width: 30.0, left: 0.0), l('def ', 4, 10, hardBreak: true, width: 30.0, left: 0.0), ]); @@ -391,7 +391,7 @@ void testMain() async { // With trailing whitespace and new lines. paragraph = plain(ahemStyle, 'abc \ndef ')..layout(constrain(50.0)); expect(paragraph.maxIntrinsicWidth, 60); - expectLines(paragraph, [ + expectLines(paragraph, [ l('abc ', 0, 5, hardBreak: true, width: 30.0, left: 0.0), l('def ', 5, 11, hardBreak: true, width: 30.0, left: 0.0), ]); @@ -399,7 +399,7 @@ void testMain() async { // Very long text. paragraph = plain(ahemStyle, 'AAAAAAAAAAAA')..layout(constrain(50.0)); expect(paragraph.maxIntrinsicWidth, 120); - expectLines(paragraph, [ + expectLines(paragraph, [ l('AAAAA', 0, 5, hardBreak: false, width: 50.0, left: 0.0), l('AAAAA', 5, 10, hardBreak: false, width: 50.0, left: 0.0), l('AA', 10, 12, hardBreak: true, width: 20.0, left: 0.0), @@ -422,7 +422,7 @@ void testMain() async { expect(longText.minIntrinsicWidth, 480); expect(longText.maxIntrinsicWidth, 480); expect(longText.height, 10); - expectLines(longText, [ + expectLines(longText, [ l('AA...', 0, 2, hardBreak: false, width: 50.0, left: 0.0), ]); @@ -435,7 +435,7 @@ void testMain() async { expect(longTextShortPrefix.minIntrinsicWidth, 450); expect(longTextShortPrefix.maxIntrinsicWidth, 450); expect(longTextShortPrefix.height, 20); - expectLines(longTextShortPrefix, [ + expectLines(longTextShortPrefix, [ l('AAA', 0, 4, hardBreak: true, width: 30.0, left: 0.0), l('AA...', 4, 6, hardBreak: false, width: 50.0, left: 0.0), ]); @@ -447,7 +447,7 @@ void testMain() async { expect(trailingSpace.minIntrinsicWidth, 30); expect(trailingSpace.maxIntrinsicWidth, 60); expect(trailingSpace.height, 10); - expectLines(trailingSpace, [ + expectLines(trailingSpace, [ l('AA...', 0, 2, hardBreak: false, width: 50.0, left: 0.0), ]); @@ -457,7 +457,7 @@ void testMain() async { expect(paragraph.minIntrinsicWidth, 40); expect(paragraph.maxIntrinsicWidth, 40); expect(paragraph.height, 10); - expectLines(paragraph, [ + expectLines(paragraph, [ l('...', 0, 0, hardBreak: false, width: 30.0, left: 0.0), ]); @@ -468,10 +468,10 @@ void testMain() async { expect(paragraph.height, 10); // TODO(flutter_web): https://github.com/flutter/flutter/issues/34346 - // expectLines(paragraph, [ + // expectLines(paragraph, [ // l('.', 0, 0, hardBreak: false, width: 10.0, left: 0.0), // ]); - expectLines(paragraph, [ + expectLines(paragraph, [ l('...', 0, 0, hardBreak: false, width: 30.0, left: 0.0), ]); }); @@ -487,7 +487,7 @@ void testMain() async { final CanvasParagraph oneline = plain(maxlinesStyle, 'One line') ..layout(constrain(double.infinity)); expect(oneline.height, 10); - expectLines(oneline, [ + expectLines(oneline, [ l('One line', 0, 8, hardBreak: true, width: 80.0, left: 0.0), ]); @@ -496,7 +496,7 @@ void testMain() async { plain(maxlinesStyle, 'First\nSecond\nThird') ..layout(constrain(double.infinity)); expect(threelines.height, 20); - expectLines(threelines, [ + expectLines(threelines, [ l('First', 0, 6, hardBreak: true, width: 50.0, left: 0.0), l('Second', 6, 13, hardBreak: true, width: 60.0, left: 0.0), ]); @@ -507,7 +507,7 @@ void testMain() async { 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', )..layout(constrain(50.0)); expect(veryLong.height, 20); - expectLines(veryLong, [ + expectLines(veryLong, [ l('Lorem ', 0, 6, hardBreak: false, width: 50.0, left: 0.0), l('ipsum ', 6, 12, hardBreak: false, width: 50.0, left: 0.0), ]); @@ -518,7 +518,7 @@ void testMain() async { 'AAA AAAAAAAAAAAAAAAAAAA', )..layout(constrain(50.0)); expect(veryLongLastLine.height, 20); - expectLines(veryLongLastLine, [ + expectLines(veryLongLastLine, [ l('AAA ', 0, 4, hardBreak: false, width: 30.0, left: 0.0), l('AAAAA', 4, 9, hardBreak: false, width: 50.0, left: 0.0), ]); @@ -543,21 +543,21 @@ void testMain() async { // Simple no overflow case. paragraph = plain(onelineStyle, 'abcdef')..layout(constrain(60.0)); expect(paragraph.height, 10); - expectLines(paragraph, [ + expectLines(paragraph, [ l('abcdef', 0, 6, hardBreak: true, width: 60.0, left: 0.0), ]); // Simple overflow case. paragraph = plain(onelineStyle, 'abcd efg')..layout(constrain(60.0)); expect(paragraph.height, 10); - expectLines(paragraph, [ + expectLines(paragraph, [ l('abc...', 0, 3, hardBreak: false, width: 60.0, left: 0.0), ]); // Another simple overflow case. paragraph = plain(onelineStyle, 'a bcde fgh')..layout(constrain(60.0)); expect(paragraph.height, 10); - expectLines(paragraph, [ + expectLines(paragraph, [ l('a b...', 0, 3, hardBreak: false, width: 60.0, left: 0.0), ]); @@ -565,7 +565,7 @@ void testMain() async { // 2nd line doesn't overflow, no ellipsis is shown. paragraph = plain(multilineStyle, 'abcdef ghijkl')..layout(constrain(60.0)); expect(paragraph.height, 20); - expectLines(paragraph, [ + expectLines(paragraph, [ l('abcdef ', 0, 7, hardBreak: false, width: 60.0, left: 0.0), l('ghijkl', 7, 13, hardBreak: true, width: 60.0, left: 0.0), ]); @@ -573,7 +573,7 @@ void testMain() async { // But when the 2nd line is long enough, the ellipsis is shown. paragraph = plain(multilineStyle, 'abcd efghijkl')..layout(constrain(60.0)); expect(paragraph.height, 20); - expectLines(paragraph, [ + expectLines(paragraph, [ l('abcd ', 0, 5, hardBreak: false, width: 40.0, left: 0.0), l('efg...', 5, 8, hardBreak: false, width: 60.0, left: 0.0), ]); @@ -583,7 +583,7 @@ void testMain() async { paragraph = plain(multilineStyle, 'abcde f gh ijk') ..layout(constrain(60.0)); expect(paragraph.height, 20); - expectLines(paragraph, [ + expectLines(paragraph, [ l('abcde ', 0, 6, hardBreak: false, width: 50.0, left: 0.0), l('f g...', 6, 9, hardBreak: false, width: 60.0, left: 0.0), ]); @@ -591,7 +591,7 @@ void testMain() async { // First line overflows but second line doesn't. paragraph = plain(multilineStyle, 'abcdefg hijk')..layout(constrain(60.0)); expect(paragraph.height, 20); - expectLines(paragraph, [ + expectLines(paragraph, [ l('abcdef', 0, 6, hardBreak: false, width: 60.0, left: 0.0), l('g hijk', 6, 12, hardBreak: true, width: 60.0, left: 0.0), ]); @@ -600,7 +600,7 @@ void testMain() async { paragraph = plain(multilineStyle, 'abcdefg hijklmnop') ..layout(constrain(60.0)); expect(paragraph.height, 20); - expectLines(paragraph, [ + expectLines(paragraph, [ l('abcdef', 0, 6, hardBreak: false, width: 60.0, left: 0.0), l('g h...', 6, 9, hardBreak: false, width: 60.0, left: 0.0), ]); @@ -620,7 +620,7 @@ void testMain() async { paragraph = plain(createStyle(ui.TextAlign.start), 'abc\ndefghi') ..layout(constrain(50.0)); - expectLines(paragraph, [ + expectLines(paragraph, [ l('abc', 0, 4, hardBreak: true, width: 30.0, left: 0.0), l('defgh', 4, 9, hardBreak: false, width: 50.0, left: 0.0), l('i', 9, 10, hardBreak: true, width: 10.0, left: 0.0), @@ -628,7 +628,7 @@ void testMain() async { paragraph = plain(createStyle(ui.TextAlign.end), 'abc\ndefghi') ..layout(constrain(50.0)); - expectLines(paragraph, [ + expectLines(paragraph, [ l('abc', 0, 4, hardBreak: true, width: 30.0, left: 20.0), l('defgh', 4, 9, hardBreak: false, width: 50.0, left: 0.0), l('i', 9, 10, hardBreak: true, width: 10.0, left: 40.0), @@ -636,7 +636,7 @@ void testMain() async { paragraph = plain(createStyle(ui.TextAlign.center), 'abc\ndefghi') ..layout(constrain(50.0)); - expectLines(paragraph, [ + expectLines(paragraph, [ l('abc', 0, 4, hardBreak: true, width: 30.0, left: 10.0), l('defgh', 4, 9, hardBreak: false, width: 50.0, left: 0.0), l('i', 9, 10, hardBreak: true, width: 10.0, left: 20.0), @@ -644,7 +644,7 @@ void testMain() async { paragraph = plain(createStyle(ui.TextAlign.left), 'abc\ndefghi') ..layout(constrain(50.0)); - expectLines(paragraph, [ + expectLines(paragraph, [ l('abc', 0, 4, hardBreak: true, width: 30.0, left: 0.0), l('defgh', 4, 9, hardBreak: false, width: 50.0, left: 0.0), l('i', 9, 10, hardBreak: true, width: 10.0, left: 0.0), @@ -652,7 +652,7 @@ void testMain() async { paragraph = plain(createStyle(ui.TextAlign.right), 'abc\ndefghi') ..layout(constrain(50.0)); - expectLines(paragraph, [ + expectLines(paragraph, [ l('abc', 0, 4, hardBreak: true, width: 30.0, left: 20.0), l('defgh', 4, 9, hardBreak: false, width: 50.0, left: 0.0), l('i', 9, 10, hardBreak: true, width: 10.0, left: 40.0), @@ -673,7 +673,7 @@ void testMain() async { paragraph = plain(createStyle(ui.TextAlign.start), 'abc\ndefghi') ..layout(constrain(50.0)); - expectLines(paragraph, [ + expectLines(paragraph, [ l('abc', 0, 4, hardBreak: true, width: 30.0, left: 20.0), l('defgh', 4, 9, hardBreak: false, width: 50.0, left: 0.0), l('i', 9, 10, hardBreak: true, width: 10.0, left: 40.0), @@ -681,7 +681,7 @@ void testMain() async { paragraph = plain(createStyle(ui.TextAlign.end), 'abc\ndefghi') ..layout(constrain(50.0)); - expectLines(paragraph, [ + expectLines(paragraph, [ l('abc', 0, 4, hardBreak: true, width: 30.0, left: 0.0), l('defgh', 4, 9, hardBreak: false, width: 50.0, left: 0.0), l('i', 9, 10, hardBreak: true, width: 10.0, left: 0.0), @@ -689,7 +689,7 @@ void testMain() async { paragraph = plain(createStyle(ui.TextAlign.center), 'abc\ndefghi') ..layout(constrain(50.0)); - expectLines(paragraph, [ + expectLines(paragraph, [ l('abc', 0, 4, hardBreak: true, width: 30.0, left: 10.0), l('defgh', 4, 9, hardBreak: false, width: 50.0, left: 0.0), l('i', 9, 10, hardBreak: true, width: 10.0, left: 20.0), @@ -697,7 +697,7 @@ void testMain() async { paragraph = plain(createStyle(ui.TextAlign.left), 'abc\ndefghi') ..layout(constrain(50.0)); - expectLines(paragraph, [ + expectLines(paragraph, [ l('abc', 0, 4, hardBreak: true, width: 30.0, left: 0.0), l('defgh', 4, 9, hardBreak: false, width: 50.0, left: 0.0), l('i', 9, 10, hardBreak: true, width: 10.0, left: 0.0), @@ -705,7 +705,7 @@ void testMain() async { paragraph = plain(createStyle(ui.TextAlign.right), 'abc\ndefghi') ..layout(constrain(50.0)); - expectLines(paragraph, [ + expectLines(paragraph, [ l('abc', 0, 4, hardBreak: true, width: 30.0, left: 20.0), l('defgh', 4, 9, hardBreak: false, width: 50.0, left: 0.0), l('i', 9, 10, hardBreak: true, width: 10.0, left: 40.0), diff --git a/lib/web_ui/test/text/layout_service_rich_test.dart b/lib/web_ui/test/text/layout_service_rich_test.dart index 892a747e64f67..c0a109b819f74 100644 --- a/lib/web_ui/test/text/layout_service_rich_test.dart +++ b/lib/web_ui/test/text/layout_service_rich_test.dart @@ -42,7 +42,7 @@ void testMain() async { await ui.webOnlyInitializeTestDomRenderer(); test('does not crash on empty spans', () { - final CanvasParagraph paragraph = rich(ahemStyle, (builder) { + final CanvasParagraph paragraph = rich(ahemStyle, (CanvasParagraphBuilder builder) { builder.pushStyle(EngineTextStyle.only(color: blue)); builder.addText(''); @@ -57,7 +57,7 @@ void testMain() async { }); test('measures spans in the same line correctly', () { - final CanvasParagraph paragraph = rich(ahemStyle, (builder) { + final CanvasParagraph paragraph = rich(ahemStyle, (CanvasParagraphBuilder builder) { builder.pushStyle(EngineTextStyle.only(fontSize: 12.0)); // 12.0 * 6 = 72.0 (with spaces) // 12.0 * 5 = 60.0 (without spaces) @@ -76,13 +76,13 @@ void testMain() async { expect(paragraph.maxIntrinsicWidth, 205.0); expect(paragraph.minIntrinsicWidth, 65.0); // "ipsum" expect(paragraph.width, double.infinity); - expectLines(paragraph, [ + expectLines(paragraph, [ l('Lorem ipsum dolor', 0, 17, hardBreak: true, width: 205.0, left: 0.0), ]); }); test('breaks lines correctly at the end of spans', () { - final CanvasParagraph paragraph = rich(ahemStyle, (builder) { + final CanvasParagraph paragraph = rich(ahemStyle, (CanvasParagraphBuilder builder) { builder.addText('Lorem '); builder.pushStyle(EngineTextStyle.only(fontSize: 15.0)); builder.addText('sit '); @@ -93,7 +93,7 @@ void testMain() async { expect(paragraph.maxIntrinsicWidth, 130.0); expect(paragraph.minIntrinsicWidth, 50.0); // "Lorem" expect(paragraph.width, 60.0); - expectLines(paragraph, [ + expectLines(paragraph, [ l('Lorem ', 0, 6, hardBreak: false, width: 50.0, left: 0.0), l('sit ', 6, 10, hardBreak: false, width: 45.0, left: 0.0), l('.', 10, 11, hardBreak: true, width: 10.0, left: 0.0), @@ -101,7 +101,7 @@ void testMain() async { }); test('breaks lines correctly in the middle of spans', () { - final CanvasParagraph paragraph = rich(ahemStyle, (builder) { + final CanvasParagraph paragraph = rich(ahemStyle, (CanvasParagraphBuilder builder) { builder.addText('Lorem ipsum '); builder.pushStyle(EngineTextStyle.only(fontSize: 11.0)); builder.addText('sit dolor'); @@ -110,7 +110,7 @@ void testMain() async { expect(paragraph.maxIntrinsicWidth, 219.0); expect(paragraph.minIntrinsicWidth, 55.0); // "dolor" expect(paragraph.width, 100.0); - expectLines(paragraph, [ + expectLines(paragraph, [ l('Lorem ', 0, 6, hardBreak: false, width: 50.0, left: 0.0), l('ipsum sit ', 6, 16, hardBreak: false, width: 93.0, left: 0.0), l('dolor', 16, 21, hardBreak: true, width: 55.0, left: 0.0), @@ -118,7 +118,7 @@ void testMain() async { }); test('handles space-only spans', () { - final CanvasParagraph paragraph = rich(ahemStyle, (builder) { + final CanvasParagraph paragraph = rich(ahemStyle, (CanvasParagraphBuilder builder) { builder.pushStyle(EngineTextStyle.only(color: red)); builder.addText('Lorem '); builder.pop(); @@ -134,14 +134,14 @@ void testMain() async { expect(paragraph.maxIntrinsicWidth, 160.0); expect(paragraph.minIntrinsicWidth, 50.0); // "Lorem" or "ipsum" expect(paragraph.width, 80.0); - expectLines(paragraph, [ + expectLines(paragraph, [ l('Lorem ', 0, 11, hardBreak: false, width: 50.0, widthWithTrailingSpaces: 110.0, left: 0.0), l('ipsum', 11, 16, hardBreak: true, width: 50.0, left: 0.0), ]); }); test('should not break at span end if it is not a line break', () { - final CanvasParagraph paragraph = rich(ahemStyle, (builder) { + final CanvasParagraph paragraph = rich(ahemStyle, (CanvasParagraphBuilder builder) { builder.pushStyle(EngineTextStyle.only(color: red)); builder.addText('Lorem'); builder.pop(); @@ -158,7 +158,7 @@ void testMain() async { expect(paragraph.maxIntrinsicWidth, 110.0); expect(paragraph.minIntrinsicWidth, 50.0); // "Lorem" or "ipsum" expect(paragraph.width, 50.0); - expectLines(paragraph, [ + expectLines(paragraph, [ l('Lorem ', 0, 6, hardBreak: false, width: 50.0, left: 0.0), l('ipsum', 6, 11, hardBreak: true, width: 50.0, left: 0.0), ]); @@ -170,14 +170,14 @@ void testMain() async { fontSize: 10, textAlign: ui.TextAlign.center, ); - final CanvasParagraph paragraph = rich(paragraphStyle, (builder) { + final CanvasParagraph paragraph = rich(paragraphStyle, (CanvasParagraphBuilder builder) { builder.addPlaceholder(300.0, 50.0, ui.PlaceholderAlignment.baseline, baseline: ui.TextBaseline.alphabetic); })..layout(constrain(500.0)); expect(paragraph.maxIntrinsicWidth, 300.0); expect(paragraph.minIntrinsicWidth, 300.0); expect(paragraph.height, 50.0); - expectLines(paragraph, [ + expectLines(paragraph, [ l('', 0, 0, hardBreak: true, width: 300.0, left: 100.0), ]); }); @@ -188,7 +188,7 @@ void testMain() async { fontSize: 10, textAlign: ui.TextAlign.center, ); - final CanvasParagraph paragraph = rich(paragraphStyle, (builder) { + final CanvasParagraph paragraph = rich(paragraphStyle, (CanvasParagraphBuilder builder) { builder.addText('abcd'); builder.addPlaceholder(300.0, 50.0, ui.PlaceholderAlignment.bottom); })..layout(constrain(400.0)); @@ -196,7 +196,7 @@ void testMain() async { expect(paragraph.maxIntrinsicWidth, 340.0); expect(paragraph.minIntrinsicWidth, 300.0); expect(paragraph.height, 50.0); - expectLines(paragraph, [ + expectLines(paragraph, [ l('abcd', 0, 4, hardBreak: true, width: 340.0, left: 30.0), ]); }); @@ -207,7 +207,7 @@ void testMain() async { fontSize: 10, textAlign: ui.TextAlign.center, ); - final CanvasParagraph paragraph = rich(paragraphStyle, (builder) { + final CanvasParagraph paragraph = rich(paragraphStyle, (CanvasParagraphBuilder builder) { builder.addText('Lorem\n'); builder.addPlaceholder(300.0, 40.0, ui.PlaceholderAlignment.bottom); builder.addText('ipsum'); @@ -217,7 +217,7 @@ void testMain() async { expect(paragraph.maxIntrinsicWidth, 300.0 + 50.0); expect(paragraph.minIntrinsicWidth, 300.0); expect(paragraph.height, 10.0 + 40.0 + 10.0); - expectLines(paragraph, [ + expectLines(paragraph, [ l('Lorem', 0, 6, hardBreak: true, width: 50.0, height: 10.0, left: 125.0), l('', 6, 6, hardBreak: false, width: 300.0, height: 40.0, left: 0.0), l('ipsum', 6, 11, hardBreak: true, width: 50.0, height: 10.0, left: 125.0), diff --git a/lib/web_ui/test/text_editing_test.dart b/lib/web_ui/test/text_editing_test.dart index 5a5ca514ea1dd..54af908e96596 100644 --- a/lib/web_ui/test/text_editing_test.dart +++ b/lib/web_ui/test/text_editing_test.dart @@ -655,7 +655,7 @@ void testMain() { createFlutterConfig( 'text', autofillHint: 'username', - autofillHintsForFields: [ + autofillHintsForFields: [ 'username', 'email', 'name', @@ -712,7 +712,7 @@ void testMain() { final Map flutterMultiAutofillElementConfig = createFlutterConfig('text', autofillHint: 'username', - autofillHintsForFields: [ + autofillHintsForFields: [ 'username', 'email', 'name', @@ -745,7 +745,7 @@ void testMain() { FormElement formElement = defaultTextEditingRoot.querySelector('form') as FormElement; final Completer submittedForm = Completer(); formElement.addEventListener( - 'submit', (event) => submittedForm.complete(true)); + 'submit', (Event event) => submittedForm.complete(true)); const MethodCall clearClient = MethodCall('TextInput.clearClient'); sendFrameworkMessage(codec.encodeMethodCall(clearClient)); @@ -765,7 +765,7 @@ void testMain() { final Map flutterMultiAutofillElementConfig = createFlutterConfig('text', autofillHint: 'username', - autofillHintsForFields: [ + autofillHintsForFields: [ 'username', 'email', 'name', @@ -798,7 +798,7 @@ void testMain() { FormElement formElement = defaultTextEditingRoot.querySelector('form') as FormElement; final Completer submittedForm = Completer(); formElement.addEventListener( - 'submit', (event) => submittedForm.complete(true)); + 'submit', (Event event) => submittedForm.complete(true)); // Clear client is not called. The used requested context to be finalized. const MethodCall finishAutofillContext = @@ -1000,7 +1000,7 @@ void testMain() { final Map flutterMultiAutofillElementConfig = createFlutterConfig('text', autofillHint: 'username', - autofillHintsForFields: [ + autofillHintsForFields: [ 'username', 'email', 'name', @@ -1229,7 +1229,7 @@ void testMain() { } else { expect( textEditing!.strategy.domElement!.classes.any( - (element) => element.toString() == 'transparentTextEditing'), + (String element) => element.toString() == 'transparentTextEditing'), isFalse); } @@ -1412,7 +1412,7 @@ void testMain() { final Map flutterMultiAutofillElementConfig = createFlutterConfig('text', autofillHint: 'email', - autofillHintsForFields: [ + autofillHintsForFields: [ hintForFirstElement, 'email', 'givenName', @@ -1681,8 +1681,8 @@ void testMain() { group('EngineAutofillForm', () { test('validate multi element form', () { final List fields = createFieldValues( - ['username', 'password', 'newPassword'], - ['field1', 'field2', 'field3']); + ['username', 'password', 'newPassword'], + ['field1', 'field2', 'field3']); final EngineAutofillForm autofillForm = EngineAutofillForm.fromFrameworkMessage( createAutofillInfo('username', 'field1'), fields)!; @@ -1733,15 +1733,15 @@ void testMain() { } else { expect( firstElement.classes.any( - (element) => element.toString() == 'transparentTextEditing'), + (String element) => element.toString() == 'transparentTextEditing'), isFalse); } }); test('validate multi element form ids sorted for form id', () { final List fields = createFieldValues( - ['username', 'password', 'newPassword'], - ['zzyyxx', 'aabbcc', 'jjkkll']); + ['username', 'password', 'newPassword'], + ['zzyyxx', 'aabbcc', 'jjkkll']); final EngineAutofillForm autofillForm = EngineAutofillForm.fromFrameworkMessage( createAutofillInfo('username', 'field1'), fields)!; @@ -1753,8 +1753,8 @@ void testMain() { expect(defaultTextEditingRoot.querySelectorAll('form'), isEmpty); final List fields = createFieldValues( - ['username', 'password', 'newPassword'], - ['field1', 'fields2', 'field3']); + ['username', 'password', 'newPassword'], + ['field1', 'fields2', 'field3']); final EngineAutofillForm autofillForm = EngineAutofillForm.fromFrameworkMessage( createAutofillInfo('username', 'field1'), fields)!; @@ -1777,7 +1777,10 @@ void testMain() { }); test('Validate single element form', () { - final List fields = createFieldValues(['username'], ['field1']); + final List fields = createFieldValues( + ['username'], + ['field1'], + ); final EngineAutofillForm autofillForm = EngineAutofillForm.fromFrameworkMessage( createAutofillInfo('username', 'field1'), fields)!; @@ -1799,7 +1802,10 @@ void testMain() { }); test('Return null if no focused element', () { - final List fields = createFieldValues(['username'], ['field1']); + final List fields = createFieldValues( + ['username'], + ['field1'], + ); final EngineAutofillForm? autofillForm = EngineAutofillForm.fromFrameworkMessage(null, fields); @@ -2126,8 +2132,8 @@ Map createFlutterConfig( Map createAutofillInfo(String hint, String uniqueId) => { 'uniqueIdentifier': uniqueId, - 'hints': [hint], - 'editingValue': { + 'hints': [hint], + 'editingValue': { 'text': 'Test', 'selectionBase': 0, 'selectionExtent': 0, @@ -2152,7 +2158,7 @@ List createFieldValues(List hints, List uniqueIds) { Map createOneFieldValue(String hint, String uniqueId) => { - 'inputType': { + 'inputType': { 'name': 'TextInputType.text', 'signed': null, 'decimal': null diff --git a/lib/web_ui/test/text_test.dart b/lib/web_ui/test/text_test.dart index c040638c25b8f..0329d6823dac6 100644 --- a/lib/web_ui/test/text_test.dart +++ b/lib/web_ui/test/text_test.dart @@ -235,20 +235,20 @@ void testMain() async { }); test('hit test on the nested text span and returns correct span offset', () { - const fontFamily = 'sans-serif'; - const fontSize = 20.0; - final style = TextStyle(fontFamily: fontFamily, fontSize: fontSize); + const String fontFamily = 'sans-serif'; + const double fontSize = 20.0; + final TextStyle style = TextStyle(fontFamily: fontFamily, fontSize: fontSize); final DomParagraphBuilder builder = DomParagraphBuilder(EngineParagraphStyle( fontFamily: fontFamily, fontSize: fontSize, )); - const text00 = 'test test test test test te00 '; - const text010 = 'test010 '; - const text02 = 'test test test test te02 '; - const text030 = 'test030 '; - const text04 = 'test test test test test test test test test test te04 '; - const text050 = 'test050 '; + const String text00 = 'test test test test test te00 '; + const String text010 = 'test010 '; + const String text02 = 'test test test test te02 '; + const String text030 = 'test030 '; + const String text04 = 'test test test test test test test test test test te04 '; + const String text050 = 'test050 '; /* Logical arrangement: Tree @@ -329,10 +329,10 @@ void testMain() async { paragraph.layout(ParagraphConstraints(width: 800)); // Reference the offsets with the output of `Display arrangement`. - const offset010 = text00.length; - const offset030 = offset010 + text010.length + text02.length; - const offset04 = offset030 + text030.length; - const offset050 = offset04 + text04.length; + const int offset010 = text00.length; + const int offset030 = offset010 + text010.length + text02.length; + const int offset04 = offset030 + text030.length; + const int offset050 = offset04 + text04.length; // Tap text010. expect(paragraph.getPositionForOffset(Offset(700, 10)).offset, offset010); // Tap text030 diff --git a/lib/web_ui/test/window_test.dart b/lib/web_ui/test/window_test.dart index 687adf4882009..2c7cc11d06301 100644 --- a/lib/web_ui/test/window_test.dart +++ b/lib/web_ui/test/window_test.dart @@ -370,7 +370,7 @@ void testMain() { }); test('cannot set url strategy after it is initialized', () async { - final testStrategy = TestUrlStrategy.fromEntry( + final TestUrlStrategy testStrategy = TestUrlStrategy.fromEntry( TestHistoryEntry('initial state', null, '/'), ); await window.debugInitializeHistory(testStrategy, useSingle: true); diff --git a/lib/web_ui/tool/unicode_sync_script.dart b/lib/web_ui/tool/unicode_sync_script.dart index 679ad6dfe55ab..5fdb3db907cc7 100644 --- a/lib/web_ui/tool/unicode_sync_script.dart +++ b/lib/web_ui/tool/unicode_sync_script.dart @@ -305,7 +305,7 @@ class PropertyCollection { .toList(); // Insert the default property if it doesn't exist. final EnumValue? found = enumCollection.values.cast().firstWhere( - (property) => property!.name == defaultProperty, + (EnumValue? property) => property!.name == defaultProperty, orElse: () => null, ); if (found == null) {