Unverified Commit 29ab437e authored by Taha Tesser's avatar Taha Tesser Committed by GitHub

Add Material 3 `CheckboxListTile` example and update existing examples (#118792)

* Add Material 3 `CheckboxListTile` example and update existing examples

* fix `list_tile.dart` doc issues

* Remove unnecessary comma
parent eced23ea
...@@ -7,46 +7,43 @@ ...@@ -7,46 +7,43 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart' show timeDilation; import 'package:flutter/scheduler.dart' show timeDilation;
void main() => runApp(const MyApp()); void main() => runApp(const CheckboxListTileApp());
class MyApp extends StatelessWidget { class CheckboxListTileApp extends StatelessWidget {
const MyApp({super.key}); const CheckboxListTileApp({super.key});
static const String _title = 'Flutter Code Sample';
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp( return const MaterialApp(
title: _title, home: CheckboxListTileExample(),
home: Scaffold(
appBar: AppBar(title: const Text(_title)),
body: const Center(
child: MyStatefulWidget(),
),
),
); );
} }
} }
class MyStatefulWidget extends StatefulWidget { class CheckboxListTileExample extends StatefulWidget {
const MyStatefulWidget({super.key}); const CheckboxListTileExample({super.key});
@override @override
State<MyStatefulWidget> createState() => _MyStatefulWidgetState(); State<CheckboxListTileExample> createState() => _CheckboxListTileExampleState();
} }
class _MyStatefulWidgetState extends State<MyStatefulWidget> { class _CheckboxListTileExampleState extends State<CheckboxListTileExample> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return CheckboxListTile( return Scaffold(
title: const Text('Animate Slowly'), appBar: AppBar(title: const Text('CheckboxListTile Sample')),
value: timeDilation != 1.0, body: Center(
onChanged: (bool? value) { child: CheckboxListTile(
setState(() { title: const Text('Animate Slowly'),
timeDilation = value! ? 10.0 : 1.0; value: timeDilation != 1.0,
}); onChanged: (bool? value) {
}, setState(() {
secondary: const Icon(Icons.hourglass_empty), timeDilation = value! ? 10.0 : 1.0;
});
},
secondary: const Icon(Icons.hourglass_empty),
),
),
); );
} }
} }
...@@ -4,99 +4,76 @@ ...@@ -4,99 +4,76 @@
// Flutter code sample for [CheckboxListTile]. // Flutter code sample for [CheckboxListTile].
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
void main() => runApp(const MyApp()); void main() => runApp(const CheckboxListTileApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
static const String _title = 'Flutter Code Sample'; class CheckboxListTileApp extends StatelessWidget {
const CheckboxListTileApp({super.key});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp( return MaterialApp(
title: _title, theme: ThemeData(colorSchemeSeed: const Color(0xff6750a4), useMaterial3: true),
home: Scaffold( home: const CheckboxListTileExample(),
appBar: AppBar(title: const Text(_title)),
body: const Center(
child: MyStatefulWidget(),
),
),
); );
} }
} }
class LinkedLabelCheckbox extends StatelessWidget { class CheckboxListTileExample extends StatefulWidget {
const LinkedLabelCheckbox({ const CheckboxListTileExample({super.key});
super.key,
required this.label,
required this.padding,
required this.value,
required this.onChanged,
});
final String label; @override
final EdgeInsets padding; State<CheckboxListTileExample> createState() => _CheckboxListTileExampleState();
final bool value; }
final ValueChanged<bool> onChanged;
class _CheckboxListTileExampleState extends State<CheckboxListTileExample> {
bool checkboxValue1 = true;
bool checkboxValue2 = true;
bool checkboxValue3 = true;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Padding( return Scaffold(
padding: padding, appBar: AppBar(title: const Text('CheckboxListTile Sample')),
child: Row( body: Column(
children: <Widget>[ children: <Widget>[
Expanded( CheckboxListTile(
child: RichText( value: checkboxValue1,
text: TextSpan( onChanged: (bool? value) {
text: label, setState(() {
style: const TextStyle( checkboxValue1 = value!;
color: Colors.blueAccent, });
decoration: TextDecoration.underline, },
), title: const Text('Headline'),
recognizer: TapGestureRecognizer() subtitle: const Text('Supporting text'),
..onTap = () { ),
debugPrint('Label has been tapped.'); const Divider(height: 0),
}, CheckboxListTile(
), value: checkboxValue2,
), onChanged: (bool? value) {
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.'),
), ),
Checkbox( const Divider(height: 0),
value: value, CheckboxListTile(
onChanged: (bool? newValue) { value: checkboxValue3,
onChanged(newValue!); onChanged: (bool? value) {
}, 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,
), ),
const Divider(height: 0),
], ],
), ),
); );
} }
} }
class MyStatefulWidget extends StatefulWidget {
const MyStatefulWidget({super.key});
@override
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
}
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
bool _isSelected = false;
@override
Widget build(BuildContext context) {
return LinkedLabelCheckbox(
label: 'Linked, tappable label text',
padding: const EdgeInsets.symmetric(horizontal: 20.0),
value: _isSelected,
onChanged: (bool newValue) {
setState(() {
_isSelected = newValue;
});
},
);
}
}
// 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 checkbox.
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
void main() => runApp(const LabeledCheckBoxApp());
class LabeledCheckBoxApp extends StatelessWidget {
const LabeledCheckBoxApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: LabeledCheckBoxExample(),
);
}
}
class LinkedLabelCheckbox extends StatelessWidget {
const LinkedLabelCheckbox({
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<bool> onChanged;
@override
Widget build(BuildContext context) {
return Padding(
padding: padding,
child: Row(
children: <Widget>[
Expanded(
child: RichText(
text: TextSpan(
text: label,
style: const TextStyle(
color: Colors.blueAccent,
decoration: TextDecoration.underline,
),
recognizer: TapGestureRecognizer()
..onTap = () {
debugPrint('Label has been tapped.');
},
),
),
),
Checkbox(
value: value,
onChanged: (bool? newValue) {
onChanged(newValue!);
},
),
],
),
);
}
}
class LabeledCheckBoxExample extends StatefulWidget {
const LabeledCheckBoxExample({super.key});
@override
State<LabeledCheckBoxExample> createState() => _LabeledCheckBoxExampleState();
}
class _LabeledCheckBoxExampleState extends State<LabeledCheckBoxExample> {
bool _isSelected = false;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Custom Labeled Checkbox Sample')),
body: Center(
child: LinkedLabelCheckbox(
label: 'Linked, tappable label text',
padding: const EdgeInsets.symmetric(horizontal: 20.0),
value: _isSelected,
onChanged: (bool newValue) {
setState(() {
_isSelected = newValue;
});
},
),
),
);
}
}
...@@ -2,27 +2,19 @@ ...@@ -2,27 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// Flutter code sample for [CheckboxListTile]. // Flutter code sample for custom labeled checkbox.
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
void main() => runApp(const MyApp()); void main() => runApp(const LabeledCheckBoxApp());
class MyApp extends StatelessWidget { class LabeledCheckBoxApp extends StatelessWidget {
const MyApp({super.key}); const LabeledCheckBoxApp({super.key});
static const String _title = 'Flutter Code Sample';
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp( return const MaterialApp(
title: _title, home: LabeledCheckBoxExample(),
home: Scaffold(
appBar: AppBar(title: const Text(_title)),
body: const Center(
child: MyStatefulWidget(),
),
),
); );
} }
} }
...@@ -65,27 +57,32 @@ class LabeledCheckbox extends StatelessWidget { ...@@ -65,27 +57,32 @@ class LabeledCheckbox extends StatelessWidget {
} }
} }
class MyStatefulWidget extends StatefulWidget { class LabeledCheckBoxExample extends StatefulWidget {
const MyStatefulWidget({super.key}); const LabeledCheckBoxExample({super.key});
@override @override
State<MyStatefulWidget> createState() => _MyStatefulWidgetState(); State<LabeledCheckBoxExample> createState() => _LabeledCheckBoxExampleState();
} }
class _MyStatefulWidgetState extends State<MyStatefulWidget> { class _LabeledCheckBoxExampleState extends State<LabeledCheckBoxExample> {
bool _isSelected = false; bool _isSelected = false;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return LabeledCheckbox( return Scaffold(
label: 'This is the label text', appBar: AppBar(title: const Text('Custom Labeled Checkbox Sample')),
padding: const EdgeInsets.symmetric(horizontal: 20.0), body: Center(
value: _isSelected, child: LabeledCheckbox(
onChanged: (bool newValue) { label: 'This is the label text',
setState(() { padding: const EdgeInsets.symmetric(horizontal: 20.0),
_isSelected = newValue; value: _isSelected,
}); onChanged: (bool newValue) {
}, setState(() {
_isSelected = newValue;
});
},
),
),
); );
} }
} }
...@@ -27,7 +27,7 @@ class ListTileExample extends StatelessWidget { ...@@ -27,7 +27,7 @@ class ListTileExample extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar(title: const Text('ListTile Sample')), appBar: AppBar(title: const Text('ListTile Sample')),
body: Column( body: ListView(
children: const <Widget>[ children: const <Widget>[
ListTile( ListTile(
leading: CircleAvatar( leading: CircleAvatar(
...@@ -37,7 +37,7 @@ class ListTileExample extends StatelessWidget { ...@@ -37,7 +37,7 @@ class ListTileExample extends StatelessWidget {
subtitle: Text('Supporting text'), subtitle: Text('Supporting text'),
trailing: Icon(Icons.favorite_rounded), trailing: Icon(Icons.favorite_rounded),
), ),
Divider(), Divider(height: 0),
ListTile( ListTile(
leading: CircleAvatar( leading: CircleAvatar(
child: Text('B') child: Text('B')
...@@ -46,7 +46,7 @@ class ListTileExample extends StatelessWidget { ...@@ -46,7 +46,7 @@ class ListTileExample extends StatelessWidget {
subtitle: Text('Longer supporting text to demonstrate how the text wraps and how the leading and trailing widgets are centered vertically with the text.'), subtitle: Text('Longer supporting text to demonstrate how the text wraps and how the leading and trailing widgets are centered vertically with the text.'),
trailing: Icon(Icons.favorite_rounded), trailing: Icon(Icons.favorite_rounded),
), ),
Divider(), Divider(height: 0),
ListTile( ListTile(
leading: CircleAvatar( leading: CircleAvatar(
child: Text('C') child: Text('C')
...@@ -56,7 +56,7 @@ class ListTileExample extends StatelessWidget { ...@@ -56,7 +56,7 @@ class ListTileExample extends StatelessWidget {
trailing: Icon(Icons.favorite_rounded), trailing: Icon(Icons.favorite_rounded),
isThreeLine: true, isThreeLine: true,
), ),
Divider(), Divider(height: 0),
], ],
), ),
); );
......
...@@ -35,54 +35,51 @@ class _ListTileExampleState extends State<ListTileExample> { ...@@ -35,54 +35,51 @@ class _ListTileExampleState extends State<ListTileExample> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar(title: const Text('ListTile Sample')), appBar: AppBar(title: const Text('ListTile Sample')),
body: Column( body: Center(
mainAxisAlignment: MainAxisAlignment.center, child: ListTile(
children: <Widget>[ enabled: _enabled,
ListTile( selected: _selected,
enabled: _enabled, onTap: () {
selected: _selected, setState(() {
onTap: () { // This is called when the user toggles the switch.
_selected = !_selected;
});
},
// This sets text color and icon color to red when list tile is disabled and
// green when list tile is selected, otherwise sets it to black.
iconColor: MaterialStateColor.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) {
return Colors.red;
}
if (states.contains(MaterialState.selected)) {
return Colors.green;
}
return Colors.black;
}),
// This sets text color and icon color to red when list tile is disabled and
// green when list tile is selected, otherwise sets it to black.
textColor: MaterialStateColor.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) {
return Colors.red;
}
if (states.contains(MaterialState.selected)) {
return Colors.green;
}
return Colors.black;
}),
leading: const Icon(Icons.person),
title: const Text('Headline'),
subtitle: Text('Enabled: $_enabled, Selected: $_selected'),
trailing: Switch(
onChanged: (bool? value) {
// This is called when the user toggles the switch.
setState(() { setState(() {
// This is called when the user toggles the switch. _enabled = value!;
_selected = !_selected;
}); });
}, },
// This sets text color and icon color to red when list tile is disabled and value: _enabled,
// green when list tile is selected, otherwise sets it to black.
iconColor: MaterialStateColor.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) {
return Colors.red;
}
if (states.contains(MaterialState.selected)) {
return Colors.green;
}
return Colors.black;
}),
// This sets text color and icon color to red when list tile is disabled and
// green when list tile is selected, otherwise sets it to black.
textColor: MaterialStateColor.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) {
return Colors.red;
}
if (states.contains(MaterialState.selected)) {
return Colors.green;
}
return Colors.black;
}),
leading: const Icon(Icons.person),
title: const Text('Headline'),
subtitle: Text('Enabled: $_enabled, Selected: $_selected'),
trailing: Switch(
onChanged: (bool? value) {
// This is called when the user toggles the switch.
setState(() {
_enabled = value!;
});
},
value: _enabled,
),
), ),
], ),
), ),
); );
} }
......
// 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/scheduler.dart';
import 'package:flutter_api_samples/material/checkbox_list_tile/checkbox_list_tile.0.dart' as example;
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('CheckboxListTile can be checked', (WidgetTester tester) async {
await tester.pumpWidget(
const example.CheckboxListTileApp(),
);
CheckboxListTile checkboxListTile = tester.widget(find.byType(CheckboxListTile));
expect(checkboxListTile.value, isFalse);
await tester.tap(find.byType(CheckboxListTile));
await tester.pump();
timeDilation = 1.0;
checkboxListTile = tester.widget(find.byType(CheckboxListTile));
expect(checkboxListTile.value, isTrue);
await tester.tap(find.byType(CheckboxListTile));
await tester.pump();
checkboxListTile = tester.widget(find.byType(CheckboxListTile));
expect(checkboxListTile.value, isFalse);
});
}
// 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/checkbox_list_tile/checkbox_list_tile.1.dart' as example;
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('Checkbox aligns appropriately', (WidgetTester tester) async {
await tester.pumpWidget(
const example.CheckboxListTileApp(),
);
expect(find.byType(CheckboxListTile), findsNWidgets(3));
Offset tileTopLeft = tester.getTopLeft(find.byType(CheckboxListTile).at(0));
Offset checkboxTopLeft = tester.getTopLeft(find.byType(Checkbox).at(0));
// The checkbox is centered vertically with the text.
expect(checkboxTopLeft - tileTopLeft, const Offset(736.0, 16.0));
tileTopLeft = tester.getTopLeft(find.byType(CheckboxListTile).at(1));
checkboxTopLeft = tester.getTopLeft(find.byType(Checkbox).at(1));
// The checkbox is centered vertically with the text.
expect(checkboxTopLeft - tileTopLeft, const Offset(736.0, 30.0));
tileTopLeft = tester.getTopLeft(find.byType(CheckboxListTile).at(2));
checkboxTopLeft = tester.getTopLeft(find.byType(Checkbox).at(2));
// The checkbox is aligned to the top vertically with the text.
expect(checkboxTopLeft - tileTopLeft, const Offset(736.0, 8.0));
});
testWidgets('Checkboxes can be checked', (WidgetTester tester) async {
await tester.pumpWidget(
const example.CheckboxListTileApp(),
);
expect(find.byType(CheckboxListTile), findsNWidgets(3));
// All checkboxes are checked.
expect(tester.widget<Checkbox>(find.byType(Checkbox).at(0)).value, isTrue);
expect(tester.widget<Checkbox>(find.byType(Checkbox).at(1)).value, isTrue);
expect(tester.widget<Checkbox>(find.byType(Checkbox).at(2)).value, isTrue);
// Tap the first checkbox.
await tester.tap(find.byType(Checkbox).at(0));
await tester.pumpAndSettle();
// The first checkbox is unchecked.
expect(tester.widget<Checkbox>(find.byType(Checkbox).at(0)).value, isFalse);
expect(tester.widget<Checkbox>(find.byType(Checkbox).at(1)).value, isTrue);
expect(tester.widget<Checkbox>(find.byType(Checkbox).at(2)).value, isTrue);
// Tap the second checkbox.
await tester.tap(find.byType(Checkbox).at(1));
await tester.pumpAndSettle();
// The first and second checkboxes are unchecked.
expect(tester.widget<Checkbox>(find.byType(Checkbox).at(0)).value, isFalse);
expect(tester.widget<Checkbox>(find.byType(Checkbox).at(1)).value, isFalse);
expect(tester.widget<Checkbox>(find.byType(Checkbox).at(2)).value, isTrue);
// Tap the third checkbox.
await tester.tap(find.byType(Checkbox).at(2));
await tester.pumpAndSettle();
// All checkboxes are unchecked.
expect(tester.widget<Checkbox>(find.byType(Checkbox).at(0)).value, isFalse);
expect(tester.widget<Checkbox>(find.byType(Checkbox).at(1)).value, isFalse);
expect(tester.widget<Checkbox>(find.byType(Checkbox).at(2)).value, isFalse);
});
}
// 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/checkbox_list_tile/custom_labeled_checkbox.0.dart' as example;
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('LinkedLabelCheckbox contains RichText and Checkbox', (WidgetTester tester) async {
await tester.pumpWidget(
const example.LabeledCheckBoxApp(),
);
// 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');
// Checkbox is initially unchecked.
Checkbox checkbox = tester.widget(find.byType(Checkbox));
expect(checkbox.value, isFalse);
// Tap the checkbox to check it.
await tester.tap(find.byType(Checkbox));
await tester.pumpAndSettle();
// Checkbox is now checked.
checkbox = tester.widget(find.byType(Checkbox));
expect(checkbox.value, isTrue);
});
}
// 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/checkbox_list_tile/custom_labeled_checkbox.1.dart' as example;
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('Tapping LabeledCheckbox toggles the checkbox', (WidgetTester tester) async {
await tester.pumpWidget(
const example.LabeledCheckBoxApp(),
);
// Checkbox is initially unchecked.
Checkbox checkbox = tester.widget(find.byType(Checkbox));
expect(checkbox.value, isFalse);
// Tap the LabeledCheckBoxApp to toggle the checkbox.
await tester.tap(find.byType(example.LabeledCheckbox));
await tester.pumpAndSettle();
// Checkbox is now checked.
checkbox = tester.widget(find.byType(Checkbox));
expect(checkbox.value, isTrue);
});
}
...@@ -85,6 +85,13 @@ import 'theme_data.dart'; ...@@ -85,6 +85,13 @@ import 'theme_data.dart';
/// ** See code in examples/api/lib/material/checkbox_list_tile/checkbox_list_tile.0.dart ** /// ** See code in examples/api/lib/material/checkbox_list_tile/checkbox_list_tile.0.dart **
/// {@end-tool} /// {@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.
///
/// ** See code in examples/api/lib/material/checkbox_list_tile/checkbox_list_tile.1.dart **
/// {@end-tool}
///
/// ## Semantics in CheckboxListTile /// ## Semantics in CheckboxListTile
/// ///
/// Since the entirety of the CheckboxListTile is interactive, it should represent /// Since the entirety of the CheckboxListTile is interactive, it should represent
...@@ -109,7 +116,7 @@ import 'theme_data.dart'; ...@@ -109,7 +116,7 @@ import 'theme_data.dart';
/// LinkedLabelCheckbox, that includes an interactive [RichText] widget that /// LinkedLabelCheckbox, that includes an interactive [RichText] widget that
/// handles tap gestures. /// handles tap gestures.
/// ///
/// ** See code in examples/api/lib/material/checkbox_list_tile/checkbox_list_tile.1.dart ** /// ** See code in examples/api/lib/material/checkbox_list_tile/custom_labeled_checkbox.0.dart **
/// {@end-tool} /// {@end-tool}
/// ///
/// ## CheckboxListTile isn't exactly what I want /// ## CheckboxListTile isn't exactly what I want
...@@ -125,7 +132,7 @@ import 'theme_data.dart'; ...@@ -125,7 +132,7 @@ import 'theme_data.dart';
/// Here is an example of a custom LabeledCheckbox widget, but you can easily /// Here is an example of a custom LabeledCheckbox widget, but you can easily
/// make your own configurable widget. /// make your own configurable widget.
/// ///
/// ** See code in examples/api/lib/material/checkbox_list_tile/checkbox_list_tile.2.dart ** /// ** See code in examples/api/lib/material/checkbox_list_tile/custom_labeled_checkbox.1.dart **
/// {@end-tool} /// {@end-tool}
/// ///
/// See also: /// See also:
......
...@@ -146,11 +146,19 @@ enum ListTileControlAffinity { ...@@ -146,11 +146,19 @@ enum ListTileControlAffinity {
/// ** See code in examples/api/lib/material/list_tile/list_tile.2.dart ** /// ** See code in examples/api/lib/material/list_tile/list_tile.2.dart **
/// {@end-tool} /// {@end-tool}
/// ///
/// {@tool dartpad}
/// This sample shows [ListTile]'s [textColor] and [iconColor] can use
/// [MaterialStateColor] color to change the color of the text and icon
/// when the [ListTile] is enabled, selected, or disabled.
///
/// ** See code in examples/api/lib/material/list_tile/list_tile.3.dart **
/// {@end-tool}
///
/// {@tool snippet}
/// To use a [ListTile] within a [Row], it needs to be wrapped in an /// To use a [ListTile] within a [Row], it needs to be wrapped in an
/// [Expanded] widget. [ListTile] requires fixed width constraints, /// [Expanded] widget. [ListTile] requires fixed width constraints,
/// whereas a [Row] does not constrain its children. /// whereas a [Row] does not constrain its children.
/// ///
/// {@tool snippet}
/// ```dart /// ```dart
/// Row( /// Row(
/// children: const <Widget>[ /// children: const <Widget>[
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment