Build a code editor with syntax highlighter using TextField in Flutter - flutter

I am trying to build Code Editor in Flutter app using TextField, I tried using flutter_syntax_view but the problem is, it only accept code as a predefined string text and it does not have any option to write a code.
This is what I have tried:
Used TextField with maxLines 10
If we can show number of lines on left like code editor
Open for suggestions, appreciate the help

See my work on github:
http://github.com/icedman/flutter_editor
It uses flutter_highlight, multicursor edits, minimap, line number gutter. Under development - you may want to contribute to that project.
I also wrote an article on creating an editor under 1000 lines of code in Flutter - wherein i explained why i ditched the textfield and made my own widget:
https://levelup.gitconnected.com/build-a-text-editor-with-flutter-ui-under-1000-lines-of-code-5a9dd2a053da

Related

dashed-vertical-line child grouping extension in flutter code

I was watching a video about a flutter project in vs code, and I saw that the developer used an extension to group sections of widgets and its childs with a dashed-vertical-line on the left side. Does anyone know what extension is used here?
That is not an extension. This is from VS code settings. Go to settings and search for FLUTTER UI you will get two options as shown in image. Select both option and restart your vs code. You will get broken line tree as you want.

How do you solve the "closing brackets syndrome" in Flutter/Dart?

I think, one of the most annoying problems when coding Flutter is when you become confused/out of sync of those closing brackets.
To me, it happens often that I add a new parent widget or insert a code snipped and then the closing curly/square/round brackets do not match, or semicolon/colon is missing... Of course, it is solvable: go to each bracket and the tooling will show you the counter-bracket and maybe you detect the discrepancy fast...or not. As you can see in the snipped, the tooling helps a bit by showing the corresponding class/widget. But to get it into sync, it always takes ages....
Do you have any best practises or hints/suggestions how to quickly adjust the brackets? What is your experience?
Thanks!
In VsCode you have some very usefull shortcuts to :
remove a widget
surround an existing widget with a new one
and more
And it handles the adding/removing of brackets :
Gif took from this answer
Quick Tip!
I use IDE integrated features to avoid mistakes and it saves my time as well. Check below example. Don't try to wrap manually.
I found this article myself quite useful when it comes to avoid bracketing mistakes and fasten developments.
There are some suggestions for you
1 - Switch to vscode its lighter, faster and you can use its intelli sense or what we call code action to add widgets and remove wherever you want in your flutter code. By doing this it will automatically take care of brackets and stuff.
2- Use flutter snippets extension there are a lot of them available on vscode at-least, not sure about android studio but the extension it will auto generate a boilerplate template for you along with the brackets
3- You can go to vscode or your android studio's flutter extension settings and customize it, there are options for auto formatting and importing as well.
4- (Optional) If you have github co-pilot then it auto suggests you about the brackets and code but not always accurate and also co-pilot is not officially available for all but its way too good to have.
You can seperate your code to functions or even better create your own Widgets. Let's
say you have to display bunch of movies as gird of cards on a main page. Instead nesting them inside giant Scaffold you can create
ListOfMovies widget using GridView which consumes List<Movie>
CardMovie widget which consumes single Movie object
Here is how I seperated them on my own project. This is not the perfect but may be helpful
Edit.
Here is another minor tip: On JetBrains IDEs you can jump to other end of brackets or curly brackets using Ctrl+Shift+M command

VS Code - Line in the middle of the screen

I'm a big fan of VS Code and i'm just learning to code. But when using dart language, there is a line in the middle of my screen the-line!!!. I don't have this trouble in html, css or any other language. I updated my graphics cards. What do you think could be the problem?
thanks
This isn't an issue with your graphics card. This is a Dart setting when you install the plugin via VS Code. You should be able to modify/remove this 'line' within the settings. It appears there is a fix here. The line is simply a formatting suggestion to where you are recommended to 'break' your code or start a new line.
Steps on getting rid of the line:
Go to your vs code and press on dart in the bottom of your screen
https://i.stack.imgur.com/hEH82.png
Then click on "Configure 'dart' language based settings..." https://i.stack.imgur.com/gWMua.png
Find the line that says "editor.rulers": [80] and change the value to what ever you want or delete the "editor.rulers" line to get rid of that huge line on your vs code screen
https://i.stack.imgur.com/Haass.png

How to prevent Visual Studio Code Flutter/Dart Editor from formatting new line/wrapping code?

I recently started working on Flutter/Dart, I like the flutter autoformatting on-save, but one thing might or might not be related is the code wrapping for long code even if code is still fitting my 4k editor window.
Is there a way to prevent new line but keep the comma auto format?
Thanks
Follow the instructions below:
Open Settings.
Expand Extensions and click Dart & Flutter on the left.
Find Dart: Line Length.
Change it to the value you want.

How do I toggle word wrap on and off in VS Code, wrapping at a specific column?

In VS Code, you can toggle word wrap on and off easily. However, I can't figure out how to toggle it based a column.
By default, I want word wrap off, so I have editor.wordWrap set to off. At times, though, I want to toggle it on for a specific editor, and I want it to wrap at column 78 (editor.wordWrapColumn set to 78). As far as I can determine, though, "View: Toggle Word Wrap" only changes editor.wordWrap from off to on. What I want would be a way to:
default editor.wordWrap to false
toggle it from false to wordWrapColumn and back again
I checked and there's no extension that will do this.
This is as of VS Code 1.20
You didn't specify which version of VS Code you were using and I'm not a pro with it by any means but I found the following article when I was researching another issue and thought it might help.
Visual Studio Code February 2017 - Editor
Because "links are not answers," the relative content is as follows:
I created an extension recently to toggle custom VS code settings, called Setting Toggle.
https://marketplace.visualstudio.com/items?itemName=Ho-Wan.setting-toggle
If you have any issues, please let me know.