Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
qiaomo opened this issue Apr 2, 2024 · 0 comments

Comments

@qiaomo
Copy link

qiaomo commented Apr 2, 2024

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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant