Unverified Commit 8d545e93 authored by jslavitz's avatar jslavitz Committed by GitHub

Add disabledThumbColor and other properties from Switch to SwitchListTile final (#22823)

* added missing properties
parent d954ae68
...@@ -74,6 +74,9 @@ class SwitchListTile extends StatelessWidget { ...@@ -74,6 +74,9 @@ class SwitchListTile extends StatelessWidget {
@required this.value, @required this.value,
@required this.onChanged, @required this.onChanged,
this.activeColor, this.activeColor,
this.activeTrackColor,
this.inactiveThumbColor,
this.inactiveTrackColor,
this.activeThumbImage, this.activeThumbImage,
this.inactiveThumbImage, this.inactiveThumbImage,
this.title, this.title,
...@@ -123,6 +126,21 @@ class SwitchListTile extends StatelessWidget { ...@@ -123,6 +126,21 @@ class SwitchListTile extends StatelessWidget {
/// Defaults to accent color of the current [Theme]. /// Defaults to accent color of the current [Theme].
final Color activeColor; final Color activeColor;
/// The color to use on the track when this switch is on.
///
/// Defaults to [ThemeData.toggleableActiveColor] with the opacity set at 50%.
final Color activeTrackColor;
/// The color to use on the thumb when this switch is off.
///
/// Defaults to the colors described in the Material design specification.
final Color inactiveThumbColor;
/// The color to use on the track when this switch is off.
///
/// Defaults to the colors described in the Material design specification.
final Color inactiveTrackColor;
/// An image to use on the thumb of this switch when the switch is on. /// An image to use on the thumb of this switch when the switch is on.
final ImageProvider activeThumbImage; final ImageProvider activeThumbImage;
...@@ -173,6 +191,9 @@ class SwitchListTile extends StatelessWidget { ...@@ -173,6 +191,9 @@ class SwitchListTile extends StatelessWidget {
activeThumbImage: activeThumbImage, activeThumbImage: activeThumbImage,
inactiveThumbImage: inactiveThumbImage, inactiveThumbImage: inactiveThumbImage,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
activeTrackColor: activeTrackColor,
inactiveTrackColor: inactiveTrackColor,
inactiveThumbColor: inactiveThumbColor,
); );
return MergeSemantics( return MergeSemantics(
child: ListTileTheme.merge( child: ListTileTheme.merge(
......
// Copyright 2018 The Chromium 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_test/flutter_test.dart';
import '../rendering/mock_canvas.dart';
void main() {
testWidgets('SwitchListTile has the right colors', (WidgetTester tester) async {
bool value = false;
await tester.pumpWidget(
MediaQuery(
data: const MediaQueryData(padding: EdgeInsets.all(8.0)),
child: Directionality(
textDirection: TextDirection.ltr,
child:
StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return Material(
child: SwitchListTile(
value: value,
onChanged: (bool newValue) {
setState(() { value = newValue; });
},
activeColor: Colors.red[500],
activeTrackColor: Colors.green[500],
inactiveThumbColor: Colors.yellow[500],
inactiveTrackColor: Colors.blue[500],
),
);
},
),
),
),
);
expect(
find.byType(Switch),
paints
..rrect(color: Colors.blue[500])
..circle(color: const Color(0x33000000))
..circle(color: const Color(0x24000000))
..circle(color: const Color(0x1f000000))
..circle(color: Colors.yellow[500])
);
await tester.tap(find.byType(Switch));
await tester.pumpAndSettle();
expect(
Material.of(tester.element(find.byType(Switch))),
paints
..rrect(color: Colors.green[500])
..circle(color: const Color(0x33000000))
..circle(color: const Color(0x24000000))
..circle(color: const Color(0x1f000000))
..circle(color: Colors.red[500])
);
});
}
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