From 0c90a719a1b91207a14b1a2ae9350e531308bd6e Mon Sep 17 00:00:00 2001 From: Bram Verhulst Date: Tue, 4 Aug 2026 20:59:23 +0200 Subject: [PATCH] fix: edit product page now moves with keyboard --- lib/views/product_form_view.dart | 14 ++++++++++++-- pubspec.yaml | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/views/product_form_view.dart b/lib/views/product_form_view.dart index 3a82d09..e13551f 100644 --- a/lib/views/product_form_view.dart +++ b/lib/views/product_form_view.dart @@ -46,7 +46,10 @@ class _ProductFormViewState extends State { @override void initState() { super.initState(); - _loadProductIfNeeded(); + WidgetsBinding.instance.addPostFrameCallback((_) { + if (!mounted) return; + _loadProductIfNeeded(); + }); } Future _loadProductIfNeeded() async { @@ -335,7 +338,7 @@ class _ProductFormViewState extends State { ), ], ), - resizeToAvoidBottomInset: false, + resizeToAvoidBottomInset: true, body: _isLoading ? const Center(child: CircularProgressIndicator()) : Center( @@ -344,6 +347,8 @@ class _ProductFormViewState extends State { child: Form( key: _formKey, child: ListView( + keyboardDismissBehavior: + ScrollViewKeyboardDismissBehavior.onDrag, padding: const EdgeInsets.all(24), children: [ _buildImagePicker(context), @@ -389,6 +394,7 @@ class _ProductFormViewState extends State { setState(() { _selectedCategory = value; }); + FocusScope.of(context).nextFocus(); }, ); }, @@ -449,6 +455,10 @@ class _ProductFormViewState extends State { border: OutlineInputBorder(), ), keyboardType: TextInputType.number, + textInputAction: TextInputAction.done, + onFieldSubmitted: (_) { + FocusScope.of(context).unfocus(); + }, validator: (value) { final number = int.tryParse(value ?? ''); diff --git a/pubspec.yaml b/pubspec.yaml index a9bd690..bf08538 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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 # 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. -version: 1.0.12 +version: 1.0.13 environment: sdk: ^3.12.2