Check If Flutter App Open or Launch First Time

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
here we'll take a look how to remember whether the user has opened our app first time or not or whether the app has been installed first time on a device or not that's why we'll take a look now here I have these three sliders as you can see and here I have this login button and now as I click on this login button actually this method should get cool so handle sign in now handle sign-in actually has a method which got save already open and after that it redirects us to another page hopefully it'll uh redirect us to login page it doesn't matter the idea is here actually so here I have this method now this method is coming from this config store file now this is my config store file this is a controller I'm using here get X you can use any kind of mechanism it doesn't matter now since this is a controller controller has a method that is called on init this is pretty much the first method that gets called as the controller gets initialized and as you can see over here at the top I have a Boolean where I declare is the first open so during this initialization I try to read this key this is a key now this key has been defined somewhere else it doesn't really matter so it has a certain value so we want to set this value through to true or false now if this value is false that means that app is not opened this uh this value is false that means that the either the app has not been open or it's not been set so we save this value this variable value in local storage so now the local storage is coming from this one so this is actually shared preference and over here as you can see we have a method get bull so this method gets cold over here so what we do we try to read this during initialization so first time definitely this is false but anyway the second method that I'm talking about that actually sets the value this value for this key as you can see this one and this one they're same so this one gets called from here and as this gets cold now it sets the value to true so that means that the app has been installed and this app has been also opened on a certain device because we set it to true so next time this app when you open this controller gets called and this would be true so if you can read that value next time of course you can read it somewhere in your app because this inside this file so inside this class controller so just go ahead and read that using get.find or there are many other ways to read that so next time when you open the app this value would return over here as a true so that means that the app has been opened so the idea is you might have a controller and in the controller first you initialize the value actually get the value whatever it is it doesn't matter and then in certain moment in your app set that key to true and if you can do that after that you can just read this one or even this one later time you'll see that this or this they both return true in that case this means that app has been opened or F has been installed like that thank you
Info
Channel: dbestech
Views: 5,502
Rating: undefined out of 5
Keywords: flutter app runs first time, check if the app launched first time or not, check if the user has opened the app first time or not, How to check first time app launch in Flutter, How to Check if an application is on its first run or One time, Flutter onboarding screen only one time
Id: Bp73MYMDQrk
Channel Id: undefined
Length: 4min 12sec (252 seconds)
Published: Mon Dec 26 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.