Exiting Focus from Multiline - Flutter

Viewed 162

I am currently trying to make a page that take notes on my app so I am using the multiline keyboard type to keep track of the text. However, I am having difficulties escaping the focus of the text. Return brings a new line (which I want it to do) but I am unsure as to when I have onSubmit or onEditingComplete because I never actually submit anything using multiline. In addition, tapping outside of the textfield does not exit the focus of the field. Here is the code that I wrote please let me know if you have any recommendations!

import 'package:flutter/material.dart';

class NoteDetail extends StatefulWidget {
  @override
  _NoteDetailState createState() => _NoteDetailState();
}

class _NoteDetailState extends State<NoteDetail> {
  @override
  Widget build(BuildContext context) {
    final dimensions = MediaQuery.of(context).size;
    return LimitedBox(
      maxHeight: dimensions.height - 100,
      maxWidth: dimensions.width - 100,
      child: Column(
        children: <Widget>[
          SizedBox(
            height: dimensions.height * 0.10,
          ),
          TextField(
            keyboardType: TextInputType.multiline,
            //this allows the text to work with multiple lines
            maxLines: null,
            //no max lines making it scroll forever
            decoration: InputDecoration(
              hintText: 'Start taking some notes',
              //shows text before the user starts to text
              focusedBorder: InputBorder.none,
              enabledBorder: InputBorder.none,
              errorBorder: InputBorder.none,
              disabledBorder: InputBorder.none,
              //this removes the border all together
              contentPadding:
                  EdgeInsets.symmetric(horizontal: dimensions.width * 0.1),
              //giving the content some padding on the side
            ),
          ),
        ],
      ),
    );
  }
}
0 Answers
Related