Skip to content

After picking the image, the footer (my custom bar) is half covered by the keyboard #237

@qiaomo

Description

@qiaomo

I am using image_picker to pick images, but after picking the image, the footer (my custom bar) is covered by the keyboard.

abc

Here's the code to reproduce:

dependencies:
  keyboard_actions: ^4.2.0
  image_picker: ^1.0.7
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import 'package:keyboard_actions/keyboard_actions.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  MyApp({super.key});

  final focusNode = FocusNode();

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      home: Scaffold(
        appBar: AppBar(
          title: const Text("Hello World"),
        ),
        body: KeyboardActions(
          config: KeyboardActionsConfig(
            keyboardActionsPlatform: KeyboardActionsPlatform.IOS,
            actions: [
              KeyboardActionsItem(
                focusNode: focusNode,
                footerBuilder: (context) {
                  return KeyboardBar();
                },
              ),
            ],
          ),
          child: TextField(
            focusNode: focusNode,
          ),
        ),
      ),
    );
  }
}

class KeyboardBar extends StatelessWidget implements PreferredSizeWidget {
  KeyboardBar({super.key});

  final _imagePicker = ImagePicker();

  @override
  Widget build(BuildContext context) {
    return Row(
      children: [
        IconButton(
          onPressed: () async {
            await _imagePicker.pickImage(source: ImageSource.gallery);
          },
          icon: const Icon(CupertinoIcons.photo_fill),
        ),
      ],
    );
  }

  @override
  Size get preferredSize => const Size.fromHeight(45);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions