Closed FoliageOwO closed 6 days ago
A FTextField
cannot have an unbound width as it will try to occupy as much horizontal space as it is given. This is similar to Flutter's inbuilt TextField
.
To fix this, you can wrap the FTextField
in either an Expanded
or a SizedBox
.
class LoginPage extends StatefulWidget {
const LoginPage({super.key});
@override
State<StatefulWidget> createState() => _LoginPageState();
}
class _LoginPageState extends State<LoginPage> {
@override
Widget build(BuildContext context) => const Row(
children: [
Text('Username'),
Expanded(child: FTextField()),
],
);
}
@Pante This is exactly what I want! I'm a newbie to Flutter
, so I don't know so much. Thanks a lot :)
No problem, glad it helped!
Describe the bug I want to let the label and the input field at the same row, like this:
not this:
Seems there's no an option to control the label position, so I tried this:
And, unfortunately, it crashed:
The content of file
file:///(path_to_the_project_root)/lib/main.dart:56:36
:To Reproduce Simply use a
FTextField
that is wrapped by aRow
, it can get crashed.Expected behavior The
FTextField
should be successfully wrapped by aRow
.Device (please complete the following information):