fix: edit product page now moves with keyboard
This commit is contained in:
@@ -46,7 +46,10 @@ class _ProductFormViewState extends State<ProductFormView> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadProductIfNeeded();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (!mounted) return;
|
||||
_loadProductIfNeeded();
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _loadProductIfNeeded() async {
|
||||
@@ -335,7 +338,7 @@ class _ProductFormViewState extends State<ProductFormView> {
|
||||
),
|
||||
],
|
||||
),
|
||||
resizeToAvoidBottomInset: false,
|
||||
resizeToAvoidBottomInset: true,
|
||||
body: _isLoading
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: Center(
|
||||
@@ -344,6 +347,8 @@ class _ProductFormViewState extends State<ProductFormView> {
|
||||
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<ProductFormView> {
|
||||
setState(() {
|
||||
_selectedCategory = value;
|
||||
});
|
||||
FocusScope.of(context).nextFocus();
|
||||
},
|
||||
);
|
||||
},
|
||||
@@ -449,6 +455,10 @@ class _ProductFormViewState extends State<ProductFormView> {
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
textInputAction: TextInputAction.done,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context).unfocus();
|
||||
},
|
||||
validator: (value) {
|
||||
final number = int.tryParse(value ?? '');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user