0

When the next line was the start alignment, the central alignment should come, and also the width of the paragraph should be reduced. Another solution required is end alignment on the next line in Textfield. ( like Final draft App or Celtx App). ex:-

short...bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb bbbbbbbb bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb bb bbbb bbbbbbbbbbbbbbb bbbbbbbbbbbbbbbbbbbbbbbb bbbbbbbbbbbbbbbbbbbbbbbbb

                                    Uncle
                   BBBBBBBBBBBBBbbbbb bbbbbbbbbbbbbbbbbbbbbbbbb
                   bbbbbbbbbbbbbbbbbbbbbbbb bbbbbbbbbbbbbbbbbbb
                   bbbbbbbbbbbbbbb bbbbbbbbbbbbbbbbbbbbbbb bbbb
                   (DIALOG)


                                                                                    CUT TO
                                                                                    (Transition)
class Popup extends StatefulWidget {
  const Popup({Key? key}) : super(key: key);

  @override
  State<Popup> createState() => _PopupState();
}

class _PopupState extends State<Popup> {
  final TextEditingController textEditor =
      TextEditingController(text: '\u200B');

  final ScrollController _scrollController = ScrollController();

  final List<String> opnTab = [
    '\u2029\u2028',
    '\u2029\u2028',
    '\u2029\u2028',
    '\u2029\u0028\u0029',
    '\u2029\u2028',
    '\u2029\u200B\u2029',
    '\u2029\u2028\u0009',
    '\u200B\u201c\u201d',
  ];
  late int preseIndex = 0;

  bool diolg = false;
  bool iconPressed = false;
  late String positionText;
  int enterCount = 0;
  @override
  void dispose() {
    _scrollController.dispose();
    textEditor.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: Scaffold(
        body: Column(
          children: [
            Expanded(
              child: Container(
                color: Colors.red,
                child: RawKeyboardListener(
                  focusNode: FocusNode(),
                  onKey: (event) {
                    if (event.isKeyPressed(LogicalKeyboardKey.enter)) {
                      preseIndex++;
                      preseIndex < opnTab.length ? preseIndex : preseIndex = 0;
                      preseIndex == 4 ? diolg = true : false;
                      int cursorPos = textEditor.selection.base.offset;
                      final String preseIndexText = opnTab[preseIndex];
                      textEditor.text =
                          '${textEditor.text}$preseIndexText\u200B';
                      textEditor.selection = TextSelection.fromPosition(
                        TextPosition(
                            offset: preseIndex == 3
                                ? opnTab[preseIndex].length + cursorPos - 1
                                : opnTab[preseIndex].length + cursorPos + 1),
                      );
                      Future.delayed(Duration(milliseconds: 50), () {
                        _scrollController.jumpTo(
                            _scrollController.positions.first.maxScrollExtent);
                      });
                    }
                  },
                  child: TextField(
                    scrollController: _scrollController,
                    keyboardType: TextInputType.visiblePassword,
                    textInputAction: TextInputAction.newline,
                    autofocus: true,
                    maxLines: null,
                    decoration: InputDecoration(
                      filled: true,
                      fillColor: Colors.yellow,
                      border: InputBorder.none,
                      isDense: true,
                    ),
                    style: TextStyle(
                      fontSize: 18,
                      wordSpacing: 5,
                    ),
                    controller: textEditor,
                  ),
                ),
              ),
            ),

        ),
      ),
    );
  }
}

Flutter Textfield in paragraph

0 Answers0