flutter_keyboard_actions icon indicating copy to clipboard operation
flutter_keyboard_actions copied to clipboard

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

Open qiaomo opened this issue 10 months ago • 0 comments

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);
}

qiaomo avatar Apr 02 '24 09:04 qiaomo