Loading...
Searching...
No Matches
Flutter Initial setup

Step 1

Add the Flutter SDK dependencies. See how to install Flutter SDK

Step 2

Android

Add following keys to project's AndroidManifest.xml located in ./android/app/src/main file

  • android.permission.ACCESS_FINE_LOCATION
  • android.permission.ACCESS_COARSE_LOCATION
  • android.permission.ACCESS_NETWORK_STATE
  • android.permission.ACCESS_WIFI_STATE
  • android.permission.CHANGE_WIFI_STATE
  • android.permission.BLUETOOTH
  • android.permission.BLUETOOTH_ADMIN
  • android.permission.BLUETOOTH_SCAN
  • android.permission.INTERNET

Example

<manifest ... >
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.INTERNET" />
</manifest>

iOS

To declare permission to use location in iOS, find a section of code at the end of the ./ios/Podfile that contains the information:

post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
...

Then add permission to use location there so that this section of code looks like this:

post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
'$(inherited)',
## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
'PERMISSION_LOCATION=1',
'PERMISSION_BLUETOOTH=1',
'PERMISSION_SENSORS=1'
]
end
end
end

After this, add the following information to ./ios/Runner/Info.plist:

  • NSMotionUsageDescription
  • NSBluetoothAlwaysUsageDescription
  • NSLocationAlwaysAndWhenInUseUsageDescription
  • NSLocationWhenInUseUsageDescription

Example

<key>NSMotionUsageDescription</key>
<string>Application needs sensors access to accurately detect movement</string>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>Application needs bluetooth access to accurately detect location</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Application needs location access to accurately detect location</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Application needs location access to accurately detect location</string>

Step 3

Request the user's permission to access their location, wifi, bluetooth etc while the app is running. This can be done, for example, using the permission_handler package.