mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
parent
8af3dde3af
commit
00a00deffc
@ -63,7 +63,7 @@ class Icon extends StatelessComponent {
|
||||
final double iconOpacity = IconTheme.of(context)?.clampedOpacity ?? 1.0;
|
||||
Color iconColor = color ?? _getDefaultColor(context);
|
||||
if (iconOpacity != 1.0)
|
||||
iconColor = iconColor.withAlpha((255.0 * iconColor.opacity * iconOpacity).round());
|
||||
iconColor = iconColor.withOpacity(iconColor.opacity * iconOpacity);
|
||||
|
||||
return new ExcludeSemantics(
|
||||
child: new SizedBox(
|
||||
|
25
packages/flutter/test/widget/icon_test.dart
Normal file
25
packages/flutter/test/widget/icon_test.dart
Normal file
@ -0,0 +1,25 @@
|
||||
// Copyright 2015 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_test/flutter_test.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
test('Can set opacity for an Icon', () {
|
||||
testWidgets((WidgetTester tester) {
|
||||
tester.pumpWidget(
|
||||
new IconTheme(
|
||||
data: new IconThemeData(
|
||||
color: Colors.green[500],
|
||||
opacity: 0.5
|
||||
),
|
||||
child: new Icon(icon: Icons.add)
|
||||
)
|
||||
);
|
||||
Text text = tester.findWidgetOfType(Text);
|
||||
expect(text.style.color, equals(Colors.green[500].withOpacity(0.5)));
|
||||
});
|
||||
});
|
||||
}
|
@ -75,6 +75,15 @@ class Instrumentation {
|
||||
});
|
||||
}
|
||||
|
||||
/// Returns the first [Widget] of the given [runtimeType], if any. Returns
|
||||
/// null if there is no matching widget.
|
||||
Widget findWidgetOfType(Type type) {
|
||||
Element element = findElement((Element element) {
|
||||
return element.widget.runtimeType == type;
|
||||
});
|
||||
return element?.widget;
|
||||
}
|
||||
|
||||
/// Returns the [State] object of the first element whose state has
|
||||
/// the given [runtimeType], if any. Returns null if there is no
|
||||
/// matching element.
|
||||
|
Loading…
Reference in New Issue
Block a user