diff --git a/examples/api/lib/material/checkbox_list_tile/checkbox_list_tile.0.dart b/examples/api/lib/material/checkbox_list_tile/checkbox_list_tile.0.dart index 01152cde30..47c3241831 100644 --- a/examples/api/lib/material/checkbox_list_tile/checkbox_list_tile.0.dart +++ b/examples/api/lib/material/checkbox_list_tile/checkbox_list_tile.0.dart @@ -14,8 +14,9 @@ class CheckboxListTileApp extends StatelessWidget { @override Widget build(BuildContext context) { - return const MaterialApp( - home: CheckboxListTileExample(), + return MaterialApp( + theme: ThemeData(useMaterial3: true), + home: const CheckboxListTileExample(), ); } } diff --git a/examples/api/lib/material/checkbox_list_tile/checkbox_list_tile.1.dart b/examples/api/lib/material/checkbox_list_tile/checkbox_list_tile.1.dart index de5bd6fb0d..a97d57a3f4 100644 --- a/examples/api/lib/material/checkbox_list_tile/checkbox_list_tile.1.dart +++ b/examples/api/lib/material/checkbox_list_tile/checkbox_list_tile.1.dart @@ -14,7 +14,7 @@ class CheckboxListTileApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( - theme: ThemeData(colorSchemeSeed: const Color(0xff6750a4), useMaterial3: true), + theme: ThemeData(useMaterial3: true), home: const CheckboxListTileExample(), ); } @@ -44,7 +44,7 @@ class _CheckboxListTileExampleState extends State { setState(() { checkboxValue1 = value!; }); - }, + }, title: const Text('Headline'), subtitle: const Text('Supporting text'), ), @@ -55,7 +55,7 @@ class _CheckboxListTileExampleState extends State { setState(() { checkboxValue2 = value!; }); - }, + }, title: const Text('Headline'), subtitle: const Text('Longer supporting text to demonstrate how the text wraps and the checkbox is centered vertically with the text.'), ), @@ -66,7 +66,7 @@ class _CheckboxListTileExampleState extends State { setState(() { checkboxValue3 = value!; }); - }, + }, title: const Text('Headline'), subtitle: const Text("Longer supporting text to demonstrate how the text wraps and how setting 'CheckboxListTile.isThreeLine = true' aligns the checkbox to the top vertically with the text."), isThreeLine: true, diff --git a/examples/api/lib/material/checkbox_list_tile/custom_labeled_checkbox.0.dart b/examples/api/lib/material/checkbox_list_tile/custom_labeled_checkbox.0.dart index fc5b0d3907..891d9181f3 100644 --- a/examples/api/lib/material/checkbox_list_tile/custom_labeled_checkbox.0.dart +++ b/examples/api/lib/material/checkbox_list_tile/custom_labeled_checkbox.0.dart @@ -8,15 +8,16 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; -void main() => runApp(const LabeledCheckBoxApp()); +void main() => runApp(const LabeledCheckboxApp()); -class LabeledCheckBoxApp extends StatelessWidget { - const LabeledCheckBoxApp({super.key}); +class LabeledCheckboxApp extends StatelessWidget { + const LabeledCheckboxApp({super.key}); @override Widget build(BuildContext context) { - return const MaterialApp( - home: LabeledCheckBoxExample(), + return MaterialApp( + theme: ThemeData(useMaterial3: true), + home: const LabeledCheckboxExample(), ); } } @@ -68,14 +69,14 @@ class LinkedLabelCheckbox extends StatelessWidget { } } -class LabeledCheckBoxExample extends StatefulWidget { - const LabeledCheckBoxExample({super.key}); +class LabeledCheckboxExample extends StatefulWidget { + const LabeledCheckboxExample({super.key}); @override - State createState() => _LabeledCheckBoxExampleState(); + State createState() => _LabeledCheckboxExampleState(); } -class _LabeledCheckBoxExampleState extends State { +class _LabeledCheckboxExampleState extends State { bool _isSelected = false; @override diff --git a/examples/api/lib/material/checkbox_list_tile/custom_labeled_checkbox.1.dart b/examples/api/lib/material/checkbox_list_tile/custom_labeled_checkbox.1.dart index 2456166220..181e485173 100644 --- a/examples/api/lib/material/checkbox_list_tile/custom_labeled_checkbox.1.dart +++ b/examples/api/lib/material/checkbox_list_tile/custom_labeled_checkbox.1.dart @@ -6,15 +6,16 @@ import 'package:flutter/material.dart'; -void main() => runApp(const LabeledCheckBoxApp()); +void main() => runApp(const LabeledCheckboxApp()); -class LabeledCheckBoxApp extends StatelessWidget { - const LabeledCheckBoxApp({super.key}); +class LabeledCheckboxApp extends StatelessWidget { + const LabeledCheckboxApp({super.key}); @override Widget build(BuildContext context) { - return const MaterialApp( - home: LabeledCheckBoxExample(), + return MaterialApp( + theme: ThemeData(useMaterial3: true), + home: const LabeledCheckboxExample(), ); } } @@ -57,14 +58,14 @@ class LabeledCheckbox extends StatelessWidget { } } -class LabeledCheckBoxExample extends StatefulWidget { - const LabeledCheckBoxExample({super.key}); +class LabeledCheckboxExample extends StatefulWidget { + const LabeledCheckboxExample({super.key}); @override - State createState() => _LabeledCheckBoxExampleState(); + State createState() => _LabeledCheckboxExampleState(); } -class _LabeledCheckBoxExampleState extends State { +class _LabeledCheckboxExampleState extends State { bool _isSelected = false; @override diff --git a/examples/api/lib/material/switch_list_tile/custom_labeled_switch.0.dart b/examples/api/lib/material/switch_list_tile/custom_labeled_switch.0.dart new file mode 100644 index 0000000000..4ad4282436 --- /dev/null +++ b/examples/api/lib/material/switch_list_tile/custom_labeled_switch.0.dart @@ -0,0 +1,100 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flutter code sample for custom labeled switch. + +import 'package:flutter/gestures.dart'; + +import 'package:flutter/material.dart'; + +void main() => runApp(const LabeledSwitchApp()); + +class LabeledSwitchApp extends StatelessWidget { + const LabeledSwitchApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: ThemeData(useMaterial3: true), + home: Scaffold( + appBar: AppBar(title: const Text('Custom Labeled Switch Sample')), + body: const Center( + child: LabeledSwitchExample(), + ), + ), + ); + } +} + +class LinkedLabelSwitch extends StatelessWidget { + const LinkedLabelSwitch({ + super.key, + required this.label, + required this.padding, + required this.value, + required this.onChanged, + }); + + final String label; + final EdgeInsets padding; + final bool value; + final ValueChanged onChanged; + + @override + Widget build(BuildContext context) { + return Padding( + padding: padding, + child: Row( + children: [ + Expanded( + child: RichText( + text: TextSpan( + text: label, + style: TextStyle( + color: Theme.of(context).colorScheme.primary, + decoration: TextDecoration.underline, + ), + recognizer: TapGestureRecognizer() + ..onTap = () { + debugPrint('Label has been tapped.'); + }, + ), + ), + ), + Switch( + value: value, + onChanged: (bool newValue) { + onChanged(newValue); + }, + ), + ], + ), + ); + } +} + +class LabeledSwitchExample extends StatefulWidget { + const LabeledSwitchExample({super.key}); + + @override + State createState() => _LabeledSwitchExampleState(); +} + +class _LabeledSwitchExampleState extends State { + bool _isSelected = false; + + @override + Widget build(BuildContext context) { + return LinkedLabelSwitch( + label: 'Linked, tappable label text', + padding: const EdgeInsets.symmetric(horizontal: 20.0), + value: _isSelected, + onChanged: (bool newValue) { + setState(() { + _isSelected = newValue; + }); + }, + ); + } +} diff --git a/examples/api/lib/material/switch_list_tile/switch_list_tile.2.dart b/examples/api/lib/material/switch_list_tile/custom_labeled_switch.1.dart similarity index 72% rename from examples/api/lib/material/switch_list_tile/switch_list_tile.2.dart rename to examples/api/lib/material/switch_list_tile/custom_labeled_switch.1.dart index 0ea6a8882a..baa7ca97f7 100644 --- a/examples/api/lib/material/switch_list_tile/switch_list_tile.2.dart +++ b/examples/api/lib/material/switch_list_tile/custom_labeled_switch.1.dart @@ -2,25 +2,23 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flutter code sample for [SwitchListTile]. +// Flutter code sample for custom labeled switch. import 'package:flutter/material.dart'; -void main() => runApp(const MyApp()); +void main() => runApp(const LabeledSwitchApp()); -class MyApp extends StatelessWidget { - const MyApp({super.key}); - - static const String _title = 'Flutter Code Sample'; +class LabeledSwitchApp extends StatelessWidget { + const LabeledSwitchApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( - title: _title, + theme: ThemeData(useMaterial3: true), home: Scaffold( - appBar: AppBar(title: const Text(_title)), + appBar: AppBar(title: const Text('Custom Labeled Switch Sample')), body: const Center( - child: MyStatefulWidget(), + child: LabeledSwitchExample(), ), ), ); @@ -65,14 +63,14 @@ class LabeledSwitch extends StatelessWidget { } } -class MyStatefulWidget extends StatefulWidget { - const MyStatefulWidget({super.key}); +class LabeledSwitchExample extends StatefulWidget { + const LabeledSwitchExample({super.key}); @override - State createState() => _MyStatefulWidgetState(); + State createState() => _LabeledSwitchExampleState(); } -class _MyStatefulWidgetState extends State { +class _LabeledSwitchExampleState extends State { bool _isSelected = false; @override diff --git a/examples/api/lib/material/switch_list_tile/switch_list_tile.0.dart b/examples/api/lib/material/switch_list_tile/switch_list_tile.0.dart index 9fb2228b68..7d2acb11e8 100644 --- a/examples/api/lib/material/switch_list_tile/switch_list_tile.0.dart +++ b/examples/api/lib/material/switch_list_tile/switch_list_tile.0.dart @@ -6,35 +6,33 @@ import 'package:flutter/material.dart'; -void main() => runApp(const MyApp()); +void main() => runApp(const SwitchListTileApp()); -class MyApp extends StatelessWidget { - const MyApp({super.key}); - - static const String _title = 'Flutter Code Sample'; +class SwitchListTileApp extends StatelessWidget { + const SwitchListTileApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( - title: _title, + theme: ThemeData(useMaterial3: true), home: Scaffold( - appBar: AppBar(title: const Text(_title)), + appBar: AppBar(title: const Text('SwitchListTile Sample')), body: const Center( - child: MyStatefulWidget(), + child: SwitchListTileExample(), ), ), ); } } -class MyStatefulWidget extends StatefulWidget { - const MyStatefulWidget({super.key}); +class SwitchListTileExample extends StatefulWidget { + const SwitchListTileExample({super.key}); @override - State createState() => _MyStatefulWidgetState(); + State createState() => _SwitchListTileExampleState(); } -class _MyStatefulWidgetState extends State { +class _SwitchListTileExampleState extends State { bool _lights = false; @override diff --git a/examples/api/lib/material/switch_list_tile/switch_list_tile.1.dart b/examples/api/lib/material/switch_list_tile/switch_list_tile.1.dart index 46d10ef9ae..0349987fe7 100644 --- a/examples/api/lib/material/switch_list_tile/switch_list_tile.1.dart +++ b/examples/api/lib/material/switch_list_tile/switch_list_tile.1.dart @@ -4,99 +4,77 @@ // Flutter code sample for [SwitchListTile]. -import 'package:flutter/gestures.dart'; - import 'package:flutter/material.dart'; -void main() => runApp(const MyApp()); +void main() => runApp(const SwitchListTileApp()); -class MyApp extends StatelessWidget { - const MyApp({super.key}); - - static const String _title = 'Flutter Code Sample'; +class SwitchListTileApp extends StatelessWidget { + const SwitchListTileApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( - title: _title, + theme: ThemeData(useMaterial3: true), home: Scaffold( - appBar: AppBar(title: const Text(_title)), - body: const Center( - child: MyStatefulWidget(), - ), - ), + appBar: AppBar(title: const Text('SwitchListTile Sample')), + body: const SwitchListTileExample()), ); } } -class LinkedLabelSwitch extends StatelessWidget { - const LinkedLabelSwitch({ - super.key, - required this.label, - required this.padding, - required this.value, - required this.onChanged, - }); +class SwitchListTileExample extends StatefulWidget { + const SwitchListTileExample({super.key}); - final String label; - final EdgeInsets padding; - final bool value; - final ValueChanged onChanged; + @override + State createState() => _SwitchListTileExampleState(); +} + +class _SwitchListTileExampleState extends State { + bool switchValue1 = true; + bool switchValue2 = true; + bool switchValue3 = true; @override Widget build(BuildContext context) { - return Padding( - padding: padding, - child: Row( + return Scaffold( + body: Column( children: [ - Expanded( - child: RichText( - text: TextSpan( - text: label, - style: const TextStyle( - color: Colors.blueAccent, - decoration: TextDecoration.underline, - ), - recognizer: TapGestureRecognizer() - ..onTap = () { - debugPrint('Label has been tapped.'); - }, - ), - ), - ), - Switch( - value: value, - onChanged: (bool newValue) { - onChanged(newValue); + SwitchListTile( + value: switchValue1, + onChanged: (bool? value) { + setState(() { + switchValue1 = value!; + }); }, + title: const Text('Headline'), + subtitle: const Text('Supporting text'), ), + const Divider(height: 0), + SwitchListTile( + value: switchValue2, + onChanged: (bool? value) { + setState(() { + switchValue2 = value!; + }); + }, + title: const Text('Headline'), + subtitle: const Text('Longer supporting text to demonstrate how the text wraps and the switch is centered vertically with the text.'), + ), + const Divider(height: 0), + SwitchListTile( + value: switchValue3, + onChanged: (bool? value) { + setState(() { + switchValue3 = value!; + }); + }, + title: const Text('Headline'), + subtitle: const Text("Longer supporting text to demonstrate how the text wraps and how setting 'SwitchListTile.isThreeLine = true' aligns the switch to the top vertically with the text."), + isThreeLine: true, + ), + const Divider(height: 0), ], ), ); } } - -class MyStatefulWidget extends StatefulWidget { - const MyStatefulWidget({super.key}); - - @override - State createState() => _MyStatefulWidgetState(); -} - -class _MyStatefulWidgetState extends State { - bool _isSelected = false; - - @override - Widget build(BuildContext context) { - return LinkedLabelSwitch( - label: 'Linked, tappable label text', - padding: const EdgeInsets.symmetric(horizontal: 20.0), - value: _isSelected, - onChanged: (bool newValue) { - setState(() { - _isSelected = newValue; - }); - }, - ); - } -} diff --git a/examples/api/test/material/checkbox_list_tile/custom_labeled_checkbox.0_test.dart b/examples/api/test/material/checkbox_list_tile/custom_labeled_checkbox.0_test.dart index a07bcd25b1..863103c927 100644 --- a/examples/api/test/material/checkbox_list_tile/custom_labeled_checkbox.0_test.dart +++ b/examples/api/test/material/checkbox_list_tile/custom_labeled_checkbox.0_test.dart @@ -9,7 +9,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('LinkedLabelCheckbox contains RichText and Checkbox', (WidgetTester tester) async { await tester.pumpWidget( - const example.LabeledCheckBoxApp(), + const example.LabeledCheckboxApp(), ); // Label text is in a RichText widget with the correct text. diff --git a/examples/api/test/material/checkbox_list_tile/custom_labeled_checkbox.1_test.dart b/examples/api/test/material/checkbox_list_tile/custom_labeled_checkbox.1_test.dart index e2498f879a..1353287ff3 100644 --- a/examples/api/test/material/checkbox_list_tile/custom_labeled_checkbox.1_test.dart +++ b/examples/api/test/material/checkbox_list_tile/custom_labeled_checkbox.1_test.dart @@ -9,7 +9,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('Tapping LabeledCheckbox toggles the checkbox', (WidgetTester tester) async { await tester.pumpWidget( - const example.LabeledCheckBoxApp(), + const example.LabeledCheckboxApp(), ); // Checkbox is initially unchecked. diff --git a/examples/api/test/material/switch_list_tile/custom_labeled_switch.0_test.dart b/examples/api/test/material/switch_list_tile/custom_labeled_switch.0_test.dart new file mode 100644 index 0000000000..a3bc6aff21 --- /dev/null +++ b/examples/api/test/material/switch_list_tile/custom_labeled_switch.0_test.dart @@ -0,0 +1,31 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/switch_list_tile/custom_labeled_switch.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('LinkedLabelSwitch contains RichText and Switch', (WidgetTester tester) async { + await tester.pumpWidget( + const example.LabeledSwitchApp(), + ); + + // Label text is in a RichText widget with the correct text. + final RichText richText = tester.widget(find.byType(RichText).first); + expect(richText.text.toPlainText(), 'Linked, tappable label text'); + + // Switch is initially off. + Switch switchWidget = tester.widget(find.byType(Switch)); + expect(switchWidget.value, isFalse); + + // Tap to toggle the switch. + await tester.tap(find.byType(Switch)); + await tester.pumpAndSettle(); + + // Switch is now on. + switchWidget = tester.widget(find.byType(Switch)); + expect(switchWidget.value, isTrue); + }); +} diff --git a/examples/api/test/material/switch_list_tile/custom_labeled_switch.1_test.dart b/examples/api/test/material/switch_list_tile/custom_labeled_switch.1_test.dart new file mode 100644 index 0000000000..65ebddb56c --- /dev/null +++ b/examples/api/test/material/switch_list_tile/custom_labeled_switch.1_test.dart @@ -0,0 +1,27 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/switch_list_tile/custom_labeled_switch.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Tapping LabeledSwitch toggles the switch', (WidgetTester tester) async { + await tester.pumpWidget( + const example.LabeledSwitchApp(), + ); + + // Switch is initially off. + Switch switchWidget = tester.widget(find.byType(Switch)); + expect(switchWidget.value, isFalse); + + // Tap to toggle the switch. + await tester.tap(find.byType(example.LabeledSwitch)); + await tester.pumpAndSettle(); + + // Switch is now on. + switchWidget = tester.widget(find.byType(Switch)); + expect(switchWidget.value, isTrue); + }); +} diff --git a/examples/api/test/material/switch_list_tile/switch_list_tile.0_test.dart b/examples/api/test/material/switch_list_tile/switch_list_tile.0_test.dart new file mode 100644 index 0000000000..2beeb5e0a0 --- /dev/null +++ b/examples/api/test/material/switch_list_tile/switch_list_tile.0_test.dart @@ -0,0 +1,26 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/switch_list_tile/switch_list_tile.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('SwitchListTile can be toggled', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SwitchListTileApp(), + ); + + expect(find.byType(SwitchListTile), findsOneWidget); + + SwitchListTile switchListTile = tester.widget(find.byType(SwitchListTile)); + expect(switchListTile.value, isFalse); + + await tester.tap(find.byType(SwitchListTile)); + await tester.pumpAndSettle(); + + switchListTile = tester.widget(find.byType(SwitchListTile)); + expect(switchListTile.value, isTrue); + }); +} diff --git a/examples/api/test/material/switch_list_tile/switch_list_tile.1_test.dart b/examples/api/test/material/switch_list_tile/switch_list_tile.1_test.dart new file mode 100644 index 0000000000..7c7eef9012 --- /dev/null +++ b/examples/api/test/material/switch_list_tile/switch_list_tile.1_test.dart @@ -0,0 +1,75 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_api_samples/material/switch_list_tile/switch_list_tile.1.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Switch aligns appropriately', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SwitchListTileApp(), + ); + + expect(find.byType(SwitchListTile), findsNWidgets(3)); + + Offset tileTopLeft = tester.getTopLeft(find.byType(SwitchListTile).at(0)); + Offset switchTopLeft = tester.getTopLeft(find.byType(Switch).at(0)); + + // The switch is centered vertically with the text. + expect(switchTopLeft - tileTopLeft, const Offset(716.0, 16.0)); + + tileTopLeft = tester.getTopLeft(find.byType(SwitchListTile).at(1)); + switchTopLeft = tester.getTopLeft(find.byType(Switch).at(1)); + + // The switch is centered vertically with the text. + expect(switchTopLeft - tileTopLeft, const Offset(716.0, 30.0)); + + tileTopLeft = tester.getTopLeft(find.byType(SwitchListTile).at(2)); + switchTopLeft = tester.getTopLeft(find.byType(Switch).at(2)); + + // The switch is aligned to the top vertically with the text. + expect(switchTopLeft - tileTopLeft, const Offset(716.0, 8.0)); + }); + + testWidgets('Switches can be checked', (WidgetTester tester) async { + await tester.pumpWidget( + const example.SwitchListTileApp(), + ); + + expect(find.byType(SwitchListTile), findsNWidgets(3)); + + // All switches are on. + expect(tester.widget(find.byType(Switch).at(0)).value, isTrue); + expect(tester.widget(find.byType(Switch).at(1)).value, isTrue); + expect(tester.widget(find.byType(Switch).at(2)).value, isTrue); + + // Tap the first switch. + await tester.tap(find.byType(Switch).at(0)); + await tester.pumpAndSettle(); + + // The first switch is off. + expect(tester.widget(find.byType(Switch).at(0)).value, isFalse); + expect(tester.widget(find.byType(Switch).at(1)).value, isTrue); + expect(tester.widget(find.byType(Switch).at(2)).value, isTrue); + + // Tap the second switch. + await tester.tap(find.byType(Switch).at(1)); + await tester.pumpAndSettle(); + + // The first and second switches are off. + expect(tester.widget(find.byType(Switch).at(0)).value, isFalse); + expect(tester.widget(find.byType(Switch).at(1)).value, isFalse); + expect(tester.widget(find.byType(Switch).at(2)).value, isTrue); + + // Tap the third switch. + await tester.tap(find.byType(Switch).at(2)); + await tester.pumpAndSettle(); + + // All switches are off. + expect(tester.widget(find.byType(Switch).at(0)).value, isFalse); + expect(tester.widget(find.byType(Switch).at(1)).value, isFalse); + expect(tester.widget(find.byType(Switch).at(2)).value, isFalse); + }); +} diff --git a/packages/flutter/lib/src/material/checkbox_list_tile.dart b/packages/flutter/lib/src/material/checkbox_list_tile.dart index 063a7e4ffc..3711e6f7f4 100644 --- a/packages/flutter/lib/src/material/checkbox_list_tile.dart +++ b/packages/flutter/lib/src/material/checkbox_list_tile.dart @@ -86,8 +86,8 @@ import 'theme_data.dart'; /// {@end-tool} /// /// {@tool dartpad} -/// This sample shows the creation of a [CheckboxListTile] using [ThemeData.useMaterial3] flag, -/// as described in: https://m3.material.io/components/lists/overview. +/// This sample demonstrates how [CheckboxListTile] positions the checkbox widget +/// relative to the text in different configurations. /// /// ** See code in examples/api/lib/material/checkbox_list_tile/checkbox_list_tile.1.dart ** /// {@end-tool} diff --git a/packages/flutter/lib/src/material/switch_list_tile.dart b/packages/flutter/lib/src/material/switch_list_tile.dart index 0b1668efb2..d2a55eee5c 100644 --- a/packages/flutter/lib/src/material/switch_list_tile.dart +++ b/packages/flutter/lib/src/material/switch_list_tile.dart @@ -89,6 +89,13 @@ enum _SwitchListTileType { material, adaptive } /// ** See code in examples/api/lib/material/switch_list_tile/switch_list_tile.0.dart ** /// {@end-tool} /// +/// {@tool dartpad} +/// This sample demonstrates how [SwitchListTile] positions the switch widget +/// relative to the text in different configurations. +/// +/// ** See code in examples/api/lib/material/switch_list_tile/switch_list_tile.1.dart ** +/// {@end-tool} +/// /// ## Semantics in SwitchListTile /// /// Since the entirety of the SwitchListTile is interactive, it should represent @@ -113,7 +120,7 @@ enum _SwitchListTileType { material, adaptive } /// LinkedLabelRadio, that includes an interactive [RichText] widget that /// handles tap gestures. /// -/// ** See code in examples/api/lib/material/switch_list_tile/switch_list_tile.1.dart ** +/// ** See code in examples/api/lib/material/switch_list_tile/custom_labeled_switch.0.dart ** /// {@end-tool} /// /// ## SwitchListTile isn't exactly what I want @@ -129,7 +136,7 @@ enum _SwitchListTileType { material, adaptive } /// Here is an example of a custom LabeledSwitch widget, but you can easily /// make your own configurable widget. /// -/// ** See code in examples/api/lib/material/switch_list_tile/switch_list_tile.2.dart ** +/// ** See code in examples/api/lib/material/switch_list_tile/custom_labeled_switch.1.dart ** /// {@end-tool} /// /// See also: