Я хочу проверить свойства некоторых виджетов, но не могу найти простой способ сделать это.
Вот простой пример с полем пароля, как я могу проверить, что для obscureText задано значение true?
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
const darkBlue = Color.fromARGB(255, 18, 32, 47);
Future<void> main() async {
testWidgets('Wheelio logo appear on the login screen',
(WidgetTester tester) async {
final Key _formKey = GlobalKey<FormState>();
final TextEditingController passwordController = TextEditingController();
const Key _passwordKey = Key('PASSWORD_KEY');
final Finder passwordField = find.byKey(_passwordKey);
await tester.pumpWidget(MaterialApp(
theme: ThemeData.dark().copyWith(scaffoldBackgroundColor: darkBlue),
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(
child: Form(
key: _formKey,
child: TextFormField(
key: _passwordKey,
obscureText: true,
controller: passwordController,
),
),
),
),
));
await tester.pump();
expect(passwordField, findsOneWidget);
final TextFormField myPasswordWidget =
tester.widget(passwordField) as TextFormField;
// How can I check that obscureText property is set to true ?
});
}