Flutter Permission Handler: Managing App Permissions Made Easy | amplifyabhi

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this Vlog we would like to see the  implementation of the permission Handler in   flutter application so in our previous tutorial  also we have dealt with the permission Handler   and there I have clearly explained you and that  is what an in detail explanation on permission   Handler and this particular tutorial is the most  updated one and also will be very much helpful   for the beginner in fetching the permission in  flutter application so I am providing the link   in the description section below for this  particular tutorial you may also go through   that particular tutorial and try comparing  these two tutorials and choose any one of   the method for fetching the permission from  the user so now let's get started with this   particular tutorial and I suggest you to follow  till the end of the tutorial because this will   be the most easiest way to handle permissions in  your flutter application so now let's get started foreign so the first thing I would like to show you is  I have added the permission Handler dependency   here and this is our latest version that is  10.2.0 and try to update the version according   to the latest available when you are trying this  particular tutorial so now let's get started with   the coding and now let's start with the basic  code implementation and if you are very much   familiar with this particular basic concepts so  you can just skip to the tutorial so now import   material dot dot here and the next one is like  void Main and now try to specify run app here   and inside which we are going to specify our my  app Here and Now let us try to declare stateless   widget my app here and then return material  app over here and inside the material app we   are going to consider scaffold which forms the  basic skeleton for our application and here we   can just specify Abba here and with the help  of a text widget you can just specify the text   inside your app bar that is the title here so now  let us try to specify permission Handler foreign let us try to specify a column and instead of a  column I am going to specify one more class here   and that is also will be a stateless widget  so in later part of the tutorial I will tell   you why I am creating one more class instead of  providing the code within this particular class   so now let us try to create one more  stateless widget here and that is   and the name of the class is home here so instead  of container here you can just specify a text   button here and inside the text button let us  try to specify some basic implementation for   now for on press here and inside the child  I am going to specify again a text widget   which is going to say like check permission  and not only checking permission here if the   permission is not provided we will also request  the user to Grant the permission as well here so   now this is the basic coding that will appear  onto our screen and also if required you can   just make the text button to the center of the  screen here by just wrapping up with the center   widget over here and now let's try to specify a  method like check permission and start creating   this particular method now and here we are going  to create this particular method and get started   with this particular implementation and the first  thing to be considered here is like this one is an   asynchronous method here because we need to wait  for some time and try to fetch the result and   not avoid here it's of a type future of void now  as we are making is of asynchronous and we need   to wait for some time like we are going to also  make use of a weight here that is we are going to   fetch the user permission and we need to wait till  the user grants the permission and then store the   status of the permission here so now final and  this one is like permission status we are going   to fetch and add a weight here and the parameter  we do require here is like permission so we are   going to get the user permission right so let us  try to specify the permission here and this is   nothing but the type of the permission so whenever  you are calling this particular method you need   to specify what permission you require or what  permission you need to check whether it is granted   or not and here making use of this particular  permission you need to request this permission   and now let us try to consider a if condition here  and inside which let us try to consider status   here and if the user has granted the permission  then you need to specify an implementation here   else you need to specify another implementation  like in else case what you need to do like you   need to request for the permission right so now  let us try to make use of a scaffold messenger   and try to display whether the permission is  granted or not or of context here show snack path   and inside which you need to specify the snack  bar and the content so now let us try to specify a   text here again try to print the or try to display  the text inside the snack bar now and here we need   context also here and here also try to pass the  context and here also try to pass the context now so Bell context and try to pass the context as  well so here when we are trying to call this   particular method let us try to add permission  Dot and here you are going to have a list of   permissions now and the first thing I just want  to have is like permission to access the photos   and here and context   so now we are good to call this particular method  and here we need to specify like if status equal   to true that is if the permission is granted  then you need to specify permission is granted and here in the else case you can also specify  like permission is not granted so now let's try to   run this particular code here and try to see and  now just try to run this particular code in our   emulator and try to observe and now here you can  see our application is now successfully installed   and now just one small change I have observed here  is like we are getting some warning message here   neither type of the appearance neither type of the  operands double equal to is subtype of the other   so now let us try to remove the comparison and  try to see okay here we have got few options   like is granted is denied is limited and all  these various options we have so now let us   try to make use of is granted here and try to  compare it so I'm just trying to rerun the code   again and now let's tap on the check permission  button here and now we have got a dialog like   allo PDF so here PDF is my application name  to access photos and videos on this device   but now there is one more important step here  you need to consider this particular step as   well so inside the Android here inside the app  directory and here insert the Manifest so just   follow this particular directory structure here  I have added few permissions over here so these   are the permissions which I have added and making  use of these particular permissions I am trying   to request the same in our flutter code that is  through our flutter application as well so make   sure you add these permissions here and try  to access them in your flutter application   and now let us try to change the permission now  so instead of photos I would like to have the   location permission here so and for the same  I have added here the location permission as   well like access course location and access find  location the difference is like you will be having   precise when you are making use of fine location  Here and Now let us try to rerun this particular   code here and try to and the previous permission  I'm just trying to allow it and now let's try to   tap on the button again and this time we have got  the location permission because we have specified   location here two points here I would like to  mention now so why I have considered the second   class like the home class here because whenever  you're trying to make use of the scaffold here   you cannot directly specify scaffold in your base  class here and the second point is like you can   just specify the permission so easily here so you  can just select the option from the drop down here   like you want to have photos audio camera contacts  all these permissions you can easily specify in   this way of fetching the permission from user so  whatever the permission you are trying to fetch   from the user in this drop down list you need to  also specify them in Android manifest as well such   that you can fetch the user permission and also  I'm trying to specify the previous tutorial Link   in the description section below and I suggest  you to go through that particular tutorial as   well and you can decide like which way of fetching  the permission is easier and flexible for you and   go accordingly and the code for this tutorial  I will be providing in the description section   below and if you are having any queries  in this particular implementation do let   me know in the comment section below so this is  it for this particular tutorial and if you like   this tutorial do like share and subscribe to our  channel for more interesting content on flutter
Info
Channel: amplifyabhi coding
Views: 7,182
Rating: undefined out of 5
Keywords:
Id: oxoN52fxJvs
Channel Id: undefined
Length: 10min 36sec (636 seconds)
Published: Mon May 22 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.