GestureDetector OnTap Delay on Android Studio / Flutter / Nexus 6 API 30 - android-studio

Think about extremly simple flutter application that contains one Container widget on the screen and GestureDetector on it.
main goes to myApp, main and myApp widgets are in the same dart file.
myApp goes to HomePage which is a different dart file.
HomePage has one Container and GestureDetector widgets.
GestureDetector's onTap function is : print('pressed');
"pressed" appears for the first time when container tapped. The problem is when I tapped for several times on this container. "pressed" appears after a delay. Sometimes I see it after compilers' message.
uid=10153(com.example.vocabulary_master_8) 1.ui identical 4 lines
Here is my flutter doctor -v finding.
[!] Android Studio (version 4.1.0)
• Android Studio at C:\Program Files\Android\Android Studio
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
After I upgrade Android Studio to 4.1.2 and Nexus 6 API 30, I started to get this error and delay.
Could you please somebody help?
Best regards.

Try printing with an integer variable that gets incremented every time you press the icon. Prints the way you want.
GestureDetector(
child: Icon(Icons.person,color: Colors.black54,),
onTap: (){
i = i+1;
print("clicked person:$i");},
behavior: HitTestBehavior.translucent
),

Firstly you should install the Dart plugin as dectected by flutter doctor.
Coming to your issue, there can be many reasons for the delay :
I guess you are running it in debug mode on an emulator, the performance in debug mode will be slow and laggy compared to release mode. To test the app in release mode, use a real device instead of an emulator and instead of flutter run, use flutter run --release.
print statement might sometimes get delayed. Instead of trying to print something try updating your UI on tap. And as seen in the above scenario, as you are tapping several times, you are forcing the debugger to print the same statement multiple times, hence in case of flutter, it check if the print statements are same or not, if they are same, it will combine all of them and print an output like this :
uid=10153(com.example.vocabulary_master_8) 1.ui identical 4 lines
after a certian delay.
So in short you code is working fine, the delay is caused because flutter takes some time to recognize and combine the similar print statements.

Yes, I also had GestureDetector is little slower in my emmulator.. I am not sure why... If you need just a Tap function then try with InkWell or Listener for better performance...

Related

How to hide warning "The console output contains very long lines (...)" when building apk in Android Studio

After I update Android Studio to chipmunk, every time I build the project it gives me this warning. Sometimes it even gives me two times in Run and Build tabs overlapping each other and consuming one click of the mouse to dismiss it, what end up being really annoying.
Is there a way to disable those bubble notifications? Disabling this specific one would be the ideal, but disabling only build notifications should work for me as well.
Thanks in advance.
In Android Studio Go to Help | Edit custom propertie
paste the following line
editor.soft.wrap.force.limit=100000

Autocomplete not working correctly in Android Studio with Flutter - First suggestions are irrelevant

I installed Flutter and Android Studio.
I ran flutter doctor - Flutter doctor
I have the Dart plugin installed - v191.8593.
When I press Ctrl + Space at a very obvious place the AutoComplete do not suggest the right suggestions.
Example:
View animation here
As you see the first suggestion are not of type ScrollPhysics and are out of context,
and after I scroll down, there are ScrollPhysics suggestions, but they are after some scrolling.
This problem can be fixed by one of the following
Invalidate caches and Restart fixed my problem.
Goto
File-> Ivalidate caches / Restart -> Invalidate and Restart
Restart Dart Analysis Server. Follow the pic below
Note all above solutions works but are not permanent as it appears there is bug in latest dart Analysis server you can follow subscribe to this reported issue for more updates
Restart Dart Analysis Server :-
Navigate to Dart Analysis tab at bottom.
Click Restart Icon (red colored icon on top left corner of Dart Analysis Window)
Wait for dart analysis to finish.
If it does not work, try this :-
Delete .packages and pubspec.lock files present in your project folder
run flutter pub get
I fix this by enable the Scope Analysis, at Dart Analysis-> Set Icon-> CheckBox.
In my case, I run in android studio terminal:
flutter upgrade
if you type stful it gives you the autocompletion of stateful widget for you.
or you have to go to
> Setting -> Editor -> Live Templates ->(choose)Flutter->(tick the option)stful
This is the image Depicting the Steps
I had the same problem and solved it by changing the first letter of my project directory's name from capital letter to lowercase letter.
Example : "My_project" => "my_project"
The solution was found there : https://github.com/flutter/flutter-intellij/issues/5978
In my case, restart android-studio worked.

No 'Remove Widget' option for flutter with Android Studio in Windows 10

Widget options (Alt+Enter) are quite helpful in Flutter Development with Android Studio. It helps us to Move, Wrap, Add, Remove or Swap Widgets automatically, basically makes our life easy.
Issue : In my IDE the 'Remove widget' option is missing. Check the image below for reference. With my fresh installation of Android Studio in two different computers, the option was never there since the beginning. I'm sure I never played or messed related configurations.
I know its not a big deal, but I'd love to have remove option as I play a lot with Widgets around and removing sometimes a pain.
Is there anything in configuration that I need to enable?
Android Studio : v3.5
The name has been changed from Remove Widget to Replace widget with its children but does the same thing.
UPDATE: Flutter has turned it back to Remove Widget.
UPDATE: From Flutter 1.12.13+hotfix.5 • channel stable The option is now back to Remove Widget.

Android Studio Update 3.3.1 debugging breakpoints executing very slowly?

I have updated my Android Studio to version 3.3.1, but now breakpoints are executing very slowly? First breakpoint take around 5 minutes to execute.
Can anyone please tell me what can I do to make it work like it was in the previous version?
I faced the same issue when I installed android studio 3.3.2. Any time I'd try to debug my app, it would run crazily slow. But finally got the solution as described below:
Go to the debugger and select view breakpoints
Make sure the Java method Breakpoint is unchecked.
It's often easy to add method breakpoints accidentally and That's usually the main reason behind the significant slowness of the debugging speed.
Follow the few steps below if that the case:
just remove all breakup points in your android studio.then automatically android debug will be fast.
remove all breakpoint step:
go to debugger then select red button it will pop up all debugger break point and then remove.

Android Studio 1.4.1 visual glitch

When I was using the Android Studio (1.4.1), after a while I ran into some visual glitches. I then fixed these by moving the window to my secondary monitor. This then happened again, after about 5 minutes.
I was wondering if this was documented, and if there is a known way to fix it.
Android Studio is having a strange "cascading display" glitch?
Try this:
Android Studio\bin\idea.properties
Add
sun.java2d.d3d=false
It seems that Java and DirectX are colliding on 2D issues.
You will have the same problem with many java apps on that graphic card.
It seems that the DirectX and Java have a collision on specific system settings.
To solve this:
In windows:
1. open Environment Variables
2. add a new variable
3. name it _JAVA_OPTIONS
4. add the following value -Dsun.java2d.d3d=false -Dsun.java2d.noddraw=true

Resources