0

How to solve this error?, i want to stack cursor tetxfield over keyboard.

Actually result

I want the result like this

I tried used stack widget but it's not work.

My source Code

Stack(
        children: [
          const Positioned.fill(
            child: Image(
              image: AssetImage('assets/images/background.png'),
              repeat: ImageRepeat.repeat,
            ),
          ),
          ListView.separated(
            itemBuilder: (_, index) => const SizedBox(),
            separatorBuilder: (_, __) => const SizedBox(
              height: 8,
            ),
            itemCount: 5,
            reverse: true,
          ),
          Positioned(
            bottom: MediaQuery.of(context).viewInsets.bottom,
            left: 0,
            right: 0,
            child: Container(
              decoration: BoxDecoration(
                color: context.theme.colorScheme.surface,
              ),
              child: Row(
                children: [
                  IconButton(
                    onPressed: () {},
                    icon: const Icon(
                      Icons.attachment_rounded,
                      color: kIconKeyboardChatColor,
                    ),
                  ),
                  const Expanded(
                    child: TextField(
                      decoration: InputDecoration(
                        enabledBorder: InputBorder.none,
                        focusedBorder: InputBorder.none,
                        hintText: 'Write a message...',
                      ),
                      keyboardType: TextInputType.multiline,
                      textInputAction: TextInputAction.newline,
                    ),
                  ),
                ],
              ),
            ),
          ),
        ],
      )

is other solution? I really appreciate your answer.

1 Answers1

0

Try to add maxLines 6 and minLines 1.

TextField(
   decoration: InputDecoration(
   enabledBorder: InputBorder.none,
   focusedBorder: InputBorder.none,
   hintText: 'Write a message...',
   textCapitalization: TextCapitalization.sentences,
   maxLines: 6,
   minLines: 1,
                      )
mario francois
  • 1,291
  • 1
  • 9
  • 16