// 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/radio/radio.1.dart' as example; import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('Radio colors can be changed', (WidgetTester tester) async { await tester.pumpWidget(const example.RadioExampleApp()); expect(find.widgetWithText(AppBar, 'Radio Sample'), findsOne); expect(find.widgetWithText(ListTile, 'Fill color'), findsOne); expect(find.widgetWithText(ListTile, 'Background color'), findsOne); expect(find.widgetWithText(ListTile, 'Side'), findsOne); expect(find.widgetWithText(ListTile, 'Inner radius'), findsOne); final Radio radioFillColor = tester .widget>( find.byType(Radio).first, ); expect( radioFillColor.fillColor!.resolve(const { WidgetState.selected, }), Colors.deepPurple, ); expect( radioFillColor.fillColor!.resolve(const {}), Colors.deepPurple.shade200, ); final Radio radioBackgroundColor = tester .widget>( find.byType(Radio).at(1), ); expect( radioBackgroundColor.backgroundColor!.resolve(const { WidgetState.selected, }), Colors.greenAccent.withValues(alpha: 0.5), ); expect( radioBackgroundColor.backgroundColor!.resolve(const {}), Colors.grey.shade300.withValues(alpha: 0.3), ); final Radio radioSide = tester .widget>( find.byType(Radio).at(2), ); expect( (radioSide.side! as WidgetStateBorderSide).resolve(const { WidgetState.selected, }), const BorderSide( color: Colors.red, width: 4, strokeAlign: BorderSide.strokeAlignCenter, ), ); expect( (radioSide.side! as WidgetStateBorderSide).resolve(const {}), const BorderSide( color: Colors.grey, width: 1.5, strokeAlign: BorderSide.strokeAlignCenter, ), ); final Radio radioInnerRadius = tester .widget>( find.byType(Radio).last, ); expect( radioInnerRadius.innerRadius!.resolve(const { WidgetState.selected, }), 6, ); }); }