From a5299065864414775cf004f423574b53b69cfc84 Mon Sep 17 00:00:00 2001 From: Mehmet Fidanboylu Date: Sat, 18 Aug 2018 20:48:38 -0700 Subject: [PATCH] Allow option switches to have keys in Gallery (#20740) * Allow option switches to have keys * Review comments --- examples/flutter_gallery/lib/gallery/options.dart | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/flutter_gallery/lib/gallery/options.dart b/examples/flutter_gallery/lib/gallery/options.dart index 640047c7f6..9463066531 100644 --- a/examples/flutter_gallery/lib/gallery/options.dart +++ b/examples/flutter_gallery/lib/gallery/options.dart @@ -115,11 +115,13 @@ class _OptionsItem extends StatelessWidget { } class _BooleanItem extends StatelessWidget { - const _BooleanItem(this.title, this.value, this.onChanged); + const _BooleanItem(this.title, this.value, this.onChanged, { this.switchKey }); final String title; final bool value; final ValueChanged onChanged; + // [switchKey] is used for accessing the switch from driver tests. + final Key switchKey; @override Widget build(BuildContext context) { @@ -129,6 +131,7 @@ class _BooleanItem extends StatelessWidget { children: [ new Expanded(child: new Text(title)), new Switch( + key: switchKey, value: value, onChanged: onChanged, activeColor: const Color(0xFF39CEFD), @@ -217,6 +220,7 @@ class _ThemeItem extends StatelessWidget { ), ); }, + switchKey: const Key('dark_theme'), ); } } @@ -285,6 +289,7 @@ class _TextDirectionItem extends StatelessWidget { ), ); }, + switchKey: const Key('text_direction'), ); } } @@ -307,6 +312,7 @@ class _TimeDilationItem extends StatelessWidget { ), ); }, + switchKey: const Key('slow_motion'), ); } }