I am wondering how to cause delay of 1-2 seconds before open the keyboard.
I'm using this command for hide the bottom navigation and the status bar:
SystemChrome.setEnabledSystemUIOverlays([]);
and when I tap on TextFormField it's causing to lag.
All I need is to delay keyboard for 1 second and restore the Overlays.
Several ways to handle this.
You could add a listener to your TextField's TextEditingController()
and run the code when it's appropriate.
TextEditingController usage Flutter Cookbook
Intentionally adding lag to your app may not be a great solution. Try not to create new problems by solving problems.
Try to identify why this is causing a delay.
Have you tested on a physical device? Sometimes the Emulator or Simulator can produce lag if you're running many tasks or on an older machine.
Try using a future!.
await Future.delayed(const Duration(seconds: 2)).then((_) {
// open keyboard
});
Related
I'm new to flutter so I apologize if this seems extremely easy to solve. I'm making an app which uses two compasses. They are put into two separate pages. When I open up the first page, the first compass works just fine. However, when I open up the second page, the second compass moves for a bit then completely stops working. When I try going back to the first page, the first compass stops working as well. I think this is because both compasses uses the same stream but I'm not too sure. The code to make the compasses I took from here: https://pub.dev/packages/flutter_compass/example. Can anyone help?
From what you have stated there can be 2 suggestive solutions from me that could for you:
You are not disposing the stream using the dispose method
#override
void dispose() {
compassController.close();
super.dispose();
}
If disposing the stream also does not work you can use Navigator.pushReplacement instead of Navigator.push which will remove the previous screen because when you push and pop the elements are not disposed(I'm still figuring the reasons behind this)
I am developing navigation to the previous pages for my flutter browser app, and to do this I am using goBack and goForward methods of InAppWebViewController.
To check whether I can go back (to change color of navigation buttons) I also call canGoBack method. As it returns Future, I am using FutureBuilder to display these icons.
I propagate canGoBack() or canGoForward() to the future field of FutureBuilder. And then a lot of strange thigs happen: sometimes when I switch between different tabs (which work similar to tabs in https://github.com/pichillilorenzo/flutter_browser_app) I receive:
MissingluginException: No implementation for method canGoForward on channel com.pichillilorenzo/flutter_inappwebview_n, where n is some number
Bug usually occur when I pop back to the widget with buttons and InAppWebView from tabs page.
I've searched all related github issues and haven't found anything related, tested on android(emulator + real device), iOS (simulator + real device) - and I cannot even see the pattern of how to reproduce this bug.
So, I have several questions:
What may be the reasons for this to happen? At first glance, it happens at random moments
What 'channel' exactly means here? I would be glad to read more about that
May it be caused because I use FutureBuilder?
As far as I can see, integration tests are good for running on a device and see how my program behaves.
The problem is that it runs too fast and I can't see anything.
I came up with solution to set await Future.delayed(Duration(seconds: 3)); in setUpAll() and after any significant action to at least see what is happenning on the screen.
Can I also see Driver taps and scrolls simulation somehow?
I tried to enter Developer Settings on my Emulator and turn on "Show taps" and "Pointer location", but it doesn't help. It shows only real taps by mouse cursor and not by FlutterDriver.
Having this function in a controller:
$scope.$on('$ionicView.enter', function() {
seemed to be good. Everytime I open the app in the real device, this functions is actually triggered. But then, after a while I realized that this is not always true.
If I open my app, and then close it. And then some time goes, maybe a few minutes. And I open the app again. Well, then the app doesnt start from scratch. It goes back to latest screen/controller I was. And, worst of all, the $ionicView.enter is NOT fired.
If the app is closed and I open again after a while (maybe 5 minutes) then it starts from beginning (showing splash etc).
So, is there a way to solve this issue? How to make the app react going into $ionicView.enter each time it is opened again? Even if picked up from background?
You could use resume event when the app picked up from background, like below:
document.addEventListener("resume", onResume, false);
function onResume() {
setTimeout(function() {
// TODO: do your thing
}, 0);
}
I am facing delay of 5 sec to show an Activity after pressing the HOME key. I had gone through some post and found that after pressing the HOME button, android prevents services and broadcast-receivers from calling startActivity for 5 seconds.
Q1. Can anyone please let me know the reason to happening this delay ?
Q2. When I modified the ActivityManagerService::checkAppSwitchAllowedLocked() to always return true, it avoids checking lock and hence Activity gets shown without any delay. Would it be a good solution to avoid delay or it may cause any wrong effect in other ways ?
I know, it's probably too late (half year passed). However, here is the answer
You won't be able to get this permission on not rooted phone, unless your application is signed with the same keys as system. Android has some permissions like that.
Also, you may be interested to check this question. Starting an activity from a service after HOME button pressed without the 5 seconds delay