import 'package:flutter/material.dart'; class SettingsTextFieldRow extends StatelessWidget { final String title; final String hintText; final TextEditingController controller; final FocusNode focusNode; final ValueChanged onChanged; final bool obscureText; const SettingsTextFieldRow({ super.key, required this.title, required this.hintText, required this.controller, required this.focusNode, required this.onChanged, this.obscureText = false, }); @override Widget build(BuildContext context) { final theme = Theme.of(context); return Padding( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), child: Row( children: [ Expanded( flex: 1, child: Text( title, maxLines: 1, overflow: TextOverflow.ellipsis, style: theme.textTheme.bodyMedium?.copyWith( fontWeight: FontWeight.w500, ), ), ), const SizedBox(width: 12), Expanded( flex: 2, child: Align( alignment: Alignment.centerRight, child: ConstrainedBox( constraints: const BoxConstraints(maxWidth: 360), child: TextField( controller: controller, focusNode: focusNode, obscureText: obscureText, onChanged: onChanged, decoration: InputDecoration( hintText: hintText, isDense: true, suffixIcon: controller.text.isEmpty ? null : IconButton( tooltip: '清空', icon: const Icon(Icons.close, size: 16), onPressed: () { controller.clear(); onChanged(''); }, ), ), ), ), ), ), ], ), ); } }