Write ahead in flutter textfield - flutter

Is there an efficient way to implement the next line completion in flutter textfield ?
The image shows the final result, the grey text is human written and the red is app generated which can be either appended to the editable on textfield or canceled.

You may add some prediction words after user's input and still keep the cursor on his/her last entered character using TextInputFormatter. Flutter already has built-in formatters like FilteringTextInputFormatter.

Just switch to text when you want to show the prediction, there is no other way to do this in flutter.
You simply cannot show other text and options on textfield in flutter

Related

Flutter OTP dots placeholders UI

I am trying to implement an OTP UI like the one in the following image with Flutter:
The idea is that the keyboard and placeholder gray dots would be always shown and when the user enters a number, the corresponding placeholder dot color should be changed to blue.
I want know how to implement the logic of changing the placeholder dot color depending on the user input?
The described logic can be implemented with a variable to store the OTP code and then use it to determine the color of the placeholder dot depending on the length of the currently entered OTP.
I have created a demo example in this link which implements the same described logic, you can run it directly from DartPad.

different text direction for different lines of a textfield in flutter

I'm making a chat app with flutter
Can anyone help me to use different text direction on each line of textfield or suggest some library for rtl and ltr?
I tried to detect text direction in textfield by intl package it works just for one line of text and set direction of textfield based on first line of text
I need something like textView in telegram app that change direction of text according to each line of text
I need exactly something like this
question different-text-direction-for-different-lines-of-a-textview
This package didn't help me [auto_direction package] (
https://pub.dev/packages/auto_direction)

Rich text components in Flutter

I would like to make a hybrid app using Flutter. One particular kind of component I'm looking at sounds something like this:
A Chinese character like 家 (which means home) is shown
When an user clicks on the character, it can display its pronunciation (jia)
The user also has the option to click to play the pronunciation
The user can also choose to open a window where an animation of how the character is being written is played.
So for a sentence like: 蓝天是白云的家(literally translated as: The blue sky is the home of the white clouds), each of these 7 characters can be individually clicked and users can choose to display / play pronunciation / show how they are written.
Normal static text won't be rich enough to display all these information. My current idea is to make every character a customized widget with such data embedded within.
This task can be quite huge if each Chinese character (there are approximately 5000 characters that are commonly used) has its own rich data format.
Any suggestions on how to approach this problem in an efficient manner in Flutter?
Thanks in advance!
There are a few ways to do this. Using widgets could definitely be an option, but that's probably going to cause you issues in the long run.
Let's break this into two parts:
1: Displaying the text
Instead of using widgets, I'd suggest using a RichText with many TextSpan children. You could create a custom class that accepts the string, splits it into characters, and puts each character in its own TextSpan. By using TextSpan.recognizer. You could then either use a TapGestureRecognizer with onTap to show the information when tapped if you don't need the position at which it was tapped, or onTapDown/onTapUp if you do (for example if you want to show a popup right where the click happened as opposed to something like a bottom sheet that comes up).
2: Showing the information
Because you're wanting to deal with a large amount of characters, I'd suggest not doing it all in code but instead handling the characters in some other sort of format that can easily be manipulated, for example JSON. That way you can do things like splitting the data it into blocks and loading them as needed, and/or getting them from a web server.
Your data could look something like:
{
"家": {
"pronunciation": "jia",
"audio": "path/to/sound.m4a",
"animation": "path/to/animation.gif"
},
...
}
You could theoretically even do things like start loading the pronunciation files when the character is first shown or when they click on it.
When the character is tapped, you could:
check if data in cache
load the data if needed from network/disk
open bottom sheet or popup displaying the pronunciation info + buttons for audio & drawing animation

How to replicate tumblr tags in flutter

I am trying to replicate the mobile tag-adding mechanism that tumblr has. I have included a picture of the screen I am talking about below.
I want to replicate the following features:
Chips are inline with text field. Text field resizes dynamically to either take the remainder of the line, or take up the next line if the content is too long
Text is turned into a chip when a comma is added (e.g. If I am typing "dog", and then I type "dog,", A "dog" chip will be created
Long chips cut off content with ellipses
Chips can be deleted with backspace
There is no text field underline decoration
Chips fill up row then wrap to next row (and entire container scrolls if there are too many rows to display simultaneously)
There are some libraries that already exist to allow a text input field with chips, but they have a lot of other features that I'm not interested in right now like the recommendation system etc, and generally just don't look the way I want with regards to multiple lines and text wrapping etc. If anyone knows how to replicate the example below, I would really appreciate it!

use tableview as uitextview

i want to develop a application like notepad app of iphone or ipod. i try my level best to design a uitextveiw like a paper with lines but it has a lot of problems like background image does not scroll with scroll of uitextview. and does not reapeat itself when text increases the background image.
its seems to me that the notepad app use a table view for taking input from user how i donot know.
so anyone who can tell me how to design a view like notepad app.
use a tableview and then place text field in each row such that if the text field limit reach the maximum length the next row text field become first responder. and when user click save then read data from all text field and then save it where u want.
but the only problem that i am facing is when the user past some data then i am unable to show that data in next text field if the past data is larger than the maximum length of a text field.
hope this help others.