Skip to main content

Posts

Showing posts from February, 2022

Request Storage Permission in Flutter

 How to Request Storage Permission in Flutter Storage permission is needed when we want the user's device to access the media or files and to perform required actions or work efficiently. In Flutter we can implement this using Storage Permission and asking user to enable the storage permission at run time. Flutter Packages required is: Permission Handler You can find these packages on pub.dev site.  Source Code: import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:permission_handler/permission_handler.dart'; void main() => runApp(MyApp()); class MyApp extends StatefulWidget {   @override   _MyAppState createState() => _MyAppState(); } class _MyAppState extends State<MyApp> {   Future<int> storagePermissionChecker;   Future<int> checkStoragePermission() async {     final result = await PermissionHandler()         .checkPermissionStatus(PermissionGroup.storage);     setState(() {});     if (re

How to Request Location permission in Flutter | Latest Version | Android Location Enable 2022

How to Request Location permission in Flutter | Latest Version | Android Location Enable 2022 Location permission is needed when we want our device to fetch the location of user's device to know the location and perform the required actions or work efficiently. In Flutter we can implement this using Location Permission and asking user to enable the location permission at run time. Flutter Packages required are: 1. Geolocator 2. Geocoding You can find these packages on pub.dev site.  Source code: import 'package:flutter/material.dart'; import 'package:geolocator/geolocator.dart'; import 'package:geocoding/geocoding.dart'; void main() {   runApp(MyApp()); } class MyApp extends StatefulWidget {   @override   _MyAppState createState() => _MyAppState(); } class _MyAppState extends State<MyApp> {   final geolocator =       Geolocator.getCurrentPosition(forceAndroidLocationManager: true);   Position _currentPosition;   String currentAddress = "";