Implements FlatButton debugFillProperties (#13217)
* Implements FlatButton debugFillDescription * Fix doc comment * Override debugFillProperties instead of debugFillDescription * Remove child debug property
This commit is contained in:
committed by
Ian Hickson
parent
bce5574cde
commit
a46679f758
@@ -162,4 +162,16 @@ class FlatButton extends StatelessWidget {
|
||||
child: child
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void debugFillProperties(DiagnosticPropertiesBuilder description) {
|
||||
super.debugFillProperties(description);
|
||||
description.add(new ObjectFlagProperty<VoidCallback>('onPressed', onPressed, ifNull: 'disabled'));
|
||||
description.add(new DiagnosticsProperty<Color>('textColor', textColor, defaultValue: null));
|
||||
description.add(new DiagnosticsProperty<Color>('disabledTextColor', disabledTextColor, defaultValue: null));
|
||||
description.add(new DiagnosticsProperty<Color>('color', color, defaultValue: null));
|
||||
description.add(new DiagnosticsProperty<Color>('highlightColor', highlightColor, defaultValue: null));
|
||||
description.add(new DiagnosticsProperty<Color>('splashColor', splashColor, defaultValue: null));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
32
packages/flutter/test/material/flat_button_test.dart
Normal file
32
packages/flutter/test/material/flat_button_test.dart
Normal file
@@ -0,0 +1,32 @@
|
||||
// Copyright 2017 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 'package:flutter/rendering.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('FlatButton implements debugFillDescription', (WidgetTester tester) async {
|
||||
final DiagnosticPropertiesBuilder builder = new DiagnosticPropertiesBuilder();
|
||||
new FlatButton(
|
||||
onPressed: () {},
|
||||
textColor: const Color(0xFF00FF00),
|
||||
disabledTextColor: const Color(0xFFFF0000),
|
||||
color: const Color(0xFF000000),
|
||||
highlightColor: const Color(0xFF1565C0),
|
||||
splashColor: const Color(0xFF9E9E9E),
|
||||
child: const Text('Hello'),
|
||||
).debugFillProperties(builder);
|
||||
final List<String> description = builder.properties
|
||||
.where((DiagnosticsNode n) => !n.isFiltered(DiagnosticLevel.info))
|
||||
.map((DiagnosticsNode n) => n.toString()).toList();
|
||||
expect(description, <String>[
|
||||
'textColor: Color(0xff00ff00)',
|
||||
'disabledTextColor: Color(0xffff0000)',
|
||||
'color: Color(0xff000000)',
|
||||
'highlightColor: Color(0xff1565c0)',
|
||||
'splashColor: Color(0xff9e9e9e)',
|
||||
]);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user