fix: edit product page now moves with keyboard

This commit is contained in:
2026-08-04 20:59:23 +02:00
parent dd5cc1e517
commit 0c90a719a1
2 changed files with 13 additions and 3 deletions
+12 -2
View File
@@ -46,7 +46,10 @@ class _ProductFormViewState extends State<ProductFormView> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_loadProductIfNeeded(); WidgetsBinding.instance.addPostFrameCallback((_) {
if (!mounted) return;
_loadProductIfNeeded();
});
} }
Future<void> _loadProductIfNeeded() async { Future<void> _loadProductIfNeeded() async {
@@ -335,7 +338,7 @@ class _ProductFormViewState extends State<ProductFormView> {
), ),
], ],
), ),
resizeToAvoidBottomInset: false, resizeToAvoidBottomInset: true,
body: _isLoading body: _isLoading
? const Center(child: CircularProgressIndicator()) ? const Center(child: CircularProgressIndicator())
: Center( : Center(
@@ -344,6 +347,8 @@ class _ProductFormViewState extends State<ProductFormView> {
child: Form( child: Form(
key: _formKey, key: _formKey,
child: ListView( child: ListView(
keyboardDismissBehavior:
ScrollViewKeyboardDismissBehavior.onDrag,
padding: const EdgeInsets.all(24), padding: const EdgeInsets.all(24),
children: [ children: [
_buildImagePicker(context), _buildImagePicker(context),
@@ -389,6 +394,7 @@ class _ProductFormViewState extends State<ProductFormView> {
setState(() { setState(() {
_selectedCategory = value; _selectedCategory = value;
}); });
FocusScope.of(context).nextFocus();
}, },
); );
}, },
@@ -449,6 +455,10 @@ class _ProductFormViewState extends State<ProductFormView> {
border: OutlineInputBorder(), border: OutlineInputBorder(),
), ),
keyboardType: TextInputType.number, keyboardType: TextInputType.number,
textInputAction: TextInputAction.done,
onFieldSubmitted: (_) {
FocusScope.of(context).unfocus();
},
validator: (value) { validator: (value) {
final number = int.tryParse(value ?? ''); final number = int.tryParse(value ?? '');
+1 -1
View File
@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts # In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix. # of the product and file versions while build-number is used as the build suffix.
version: 1.0.12 version: 1.0.13
environment: environment:
sdk: ^3.12.2 sdk: ^3.12.2