Retain the toString method for subclasses of Key in profile/release mode (#149926)
toString methods are removed in AOT builds by the optimization in https://github.com/flutter/flutter/pull/144763 This PR disables that for Key subclasses because some applications rely on the previous behavior. Fixes https://github.com/flutter/flutter/issues/148983
This commit is contained in:
parent
2d0a0237d2
commit
4e6e61dfd5
@ -17,6 +17,14 @@ Future<void> main() async {
|
|||||||
// regression test for https://github.com/flutter/flutter/issues/49601
|
// regression test for https://github.com/flutter/flutter/issues/49601
|
||||||
final List<int> computed = await compute(_utf8Encode, 'test');
|
final List<int> computed = await compute(_utf8Encode, 'test');
|
||||||
print(computed);
|
print(computed);
|
||||||
|
|
||||||
|
// regression test for https://github.com/flutter/flutter/issues/148983
|
||||||
|
const String value = 'testValueKey';
|
||||||
|
const ValueKey<String> valueKey = ValueKey<String>(value);
|
||||||
|
if (!valueKey.toString().contains(value)) {
|
||||||
|
throw Exception('ValueKey string does not contain the value');
|
||||||
|
}
|
||||||
|
|
||||||
runApp(
|
runApp(
|
||||||
const Center(
|
const Center(
|
||||||
child: text,
|
child: text,
|
||||||
|
@ -21,6 +21,7 @@ import 'diagnostics.dart';
|
|||||||
///
|
///
|
||||||
/// * [Widget.key], which discusses how widgets use keys.
|
/// * [Widget.key], which discusses how widgets use keys.
|
||||||
@immutable
|
@immutable
|
||||||
|
@pragma('flutter:keep-to-string-in-subtypes')
|
||||||
abstract class Key {
|
abstract class Key {
|
||||||
/// Construct a [ValueKey<String>] with the given [String].
|
/// Construct a [ValueKey<String>] with the given [String].
|
||||||
///
|
///
|
||||||
|
Loading…
x
Reference in New Issue
Block a user