-
Notifications
You must be signed in to change notification settings - Fork 6k
[web] Warn users when picking a deprecated renderer. #55709
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,19 @@ abstract class Renderer { | |
| useCanvasKit = FlutterConfiguration.useSkia; | ||
| } | ||
|
|
||
| // Warn users in development that anything other than canvaskit is deprecated. | ||
| assert(() { | ||
| if (!useCanvasKit) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this trigger if you pick
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When we hit this if, we know that the HTMLRenderer is going to be chosen, this is only trying to reconstruct why. I think the only corner case that this won't pick up at runtime is if the user has set That's why we need a tool change in
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the value of
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we could've done: if (FlutterConfiguration.flutterWebAutoDetect || !useCanvasKit) {to capture all cases we want to warn against. |
||
| // The user requested 'html' or 'auto' either in the command-line or JS. | ||
| final String requested = | ||
| configuration.requestedRendererType ?? | ||
| (FlutterConfiguration.flutterWebAutoDetect ? 'auto' : 'html'); | ||
| printWarning( | ||
| 'The HTML Renderer is being deprecated. Stop using the "$requested" renderer mode.' | ||
| '\nSee: https://docs.flutter.dev/to/web-html-renderer-deprecation'); | ||
| } | ||
| return true; | ||
| }()); | ||
| return useCanvasKit ? CanvasKitRenderer() : HtmlRenderer(); | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| import 'package:test/bootstrap/browser.dart'; | ||
| import 'package:test/test.dart'; | ||
| import 'package:ui/src/engine.dart'; | ||
|
|
||
| void main() { | ||
| internalBootstrapBrowserTest(() => testMain); | ||
| } | ||
|
|
||
| void testMain() { | ||
| final List<String> warnings = <String>[]; | ||
| late void Function(String) oldPrintWarning; | ||
|
|
||
| setUpAll(() async { | ||
| oldPrintWarning = printWarning; | ||
| printWarning = (String warning) { | ||
| warnings.add(warning); | ||
| }; | ||
| }); | ||
|
|
||
| tearDownAll(() { | ||
| printWarning = oldPrintWarning; | ||
| }); | ||
|
|
||
| test('Emit a warning when the HTML Renderer was picked.', () { | ||
| final Renderer chosenRenderer = renderer; | ||
|
|
||
| expect(chosenRenderer, isA<HtmlRenderer>()); | ||
| expect(warnings, contains( | ||
| contains('See: https://docs.flutter.dev/to/web-html-renderer-deprecation') | ||
| )); | ||
| }); | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.