Open rafmsou opened 7 months ago
flutter version:
Flutter 3.16.3 • channel stable • https://github.com/flutter/flutter.git
Framework • revision b0366e0a3f (8 weeks ago) • 2023-12-05 19:46:39 -0800
Engine • revision 54a7145303
Tools • Dart 3.2.3 • DevTools 2.28.4
code to reproduce:
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_web_frame/flutter_web_frame.dart';
/// Flutter code sample for [TextFormField].
void main() => runApp(const TextFormFieldExampleApp());
class TextFormFieldExampleApp extends StatelessWidget {
const TextFormFieldExampleApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: TextFormFieldExample(),
);
}
}
class TextFormFieldExample extends StatefulWidget {
const TextFormFieldExample({super.key});
@override
State<TextFormFieldExample> createState() => _TextFormFieldExampleState();
}
class _TextFormFieldExampleState extends State<TextFormFieldExample> {
@override
Widget build(BuildContext context) {
return FlutterWebFrame(
maximumSize: const Size(475.0, 0), // Maximum size
enabled: kIsWeb, // default is enable, when disable content is full size
backgroundColor: Colors.grey, // Background color/white space
builder: (context) {
return Material(
child: Center(
child: Shortcuts(
shortcuts: const <ShortcutActivator, Intent>{
// Pressing space in the field will now move to the next field.
SingleActivator(LogicalKeyboardKey.space): NextFocusIntent(),
},
child: FocusTraversalGroup(
child: Form(
autovalidateMode: AutovalidateMode.always,
onChanged: () {
Form.of(primaryFocus!.context!).save();
},
child: Wrap(
children: List<Widget>.generate(5, (int index) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: ConstrainedBox(
constraints: BoxConstraints.tight(const Size(200, 50)),
child: TextFormField(
onSaved: (String? value) {
debugPrint(
'Value for field $index saved as "$value"');
},
),
),
);
}),
),
),
),
),
),
);
}
);
}
}
I thought it would be no problem to set max height to zero since my only interest was to constrain width:
However this caused a lot of issues on form inputs (text fields) and other widgets. For the most part app runs fine we only see errors when focusing or tapping these widgets.
One error for example is:
Another exception was thrown: Unsupported operation: Infinity
when focusing a text field.Should we raise an error or validate somehow that these constraints should not be set to zero?
I'd be willing to open up a PR for that, thanks!!