Learn/Platform Integration/Permissions & Deep Linking

Permissions & Deep Linking

Handle runtime permissions and deep link navigation

6 min~6 min read+45 FX

You can read this lesson publicly. Sign in to unlock exercises, quiz, and FX progress tracking.

Table of Contents

  1. 1. Permission UX Strategy
  2. 2. This Lesson In Simple Words
  3. 3. Your level focus
  4. 4. One practical habit
  5. 5. Deep Understanding Guide
  6. 6. Why this lesson matters
  7. 7. Study flow for better retention
  8. 8. Quick Glossary
  9. 9. Architecture Lens

Having trouble? AI is here to help

Ask context-aware questions about this lesson. Free plan: 5 questions/day. Upgrade to Premium for higher daily limits.

Use the AI button at the bottom of the screen

Permissions & Deep Linking

Permissions are required to access sensitive device features like the camera, microphone, location, and storage. On both Android and iOS, users must explicitly grant permission before your app can use these features. The permission_handler package provides a unified Dart API for requesting and checking permission status across platforms. Permissions can be in one of several states including granted, denied, and permanently denied. When a user permanently denies a permission, the system will not show the permission dialog again and you must guide the user to the app settings screen. Deep links allow users to open a specific screen inside your app directly from a URL. For example, a URL like myapp.com/product/123 can open your app and navigate straight to the product detail screen for item 123. On Android, deep links are configured through intent filters in AndroidManifest.xml. On iOS, they are set up through Associated Domains in Xcode. The go_router package is the officially recommended routing solution that simplifies deep link handling with path parameters, query parameters, and redirect logic.

dart
1// ── PERMISSIONS ──
2// pubspec.yaml: permission_handler: ^11.0.0
3import 'package:permission_handler/permission_handler.dart';
4
5// Request camera permission
6Future<bool> requestCamera() async {
7 final status = await Permission.camera.request();
8
9 if (status.isGranted) {
10 return true;
11 } else if (status.isDenied) {
12 // User denied, can ask again
13 return false;
14 } else if (status.isPermanentlyDenied) {
15 // User permanently denied: open settings
16 await openAppSettings();
17 return false;
18 }
19 return false;
20}
21
22// Check multiple permissions
23Future<void> checkPermissions() async {
24 Map<Permission, PermissionStatus> statuses = await [
25 Permission.camera,
26 Permission.microphone,
27 Permission.location,
28 ].request();
29
30 if (statuses[Permission.camera]!.isGranted) {
31 print('Camera granted');
32 }
33}
dart
1// ── DEEP LINKING ──
2// In MaterialApp:
3MaterialApp(
4 // Handle deep links
5 onGenerateRoute: (settings) {
6 final uri = Uri.parse(settings.name ?? '');
7
8 // myapp://product/123
9 if (uri.pathSegments.length == 2 && uri.pathSegments[0] == 'product') {
10 final id = uri.pathSegments[1];
11 return MaterialPageRoute(
12 builder: (_) => ProductDetailScreen(productId: id),
13 );
14 }
15 return MaterialPageRoute(builder: (_) => const HomeScreen());
16 },
17)
18
19// ── With go_router (recommended) ──
20// pubspec.yaml: go_router: ^12.0.0
21final router = GoRouter(
22 routes: [
23 GoRoute(
24 path: '/',
25 builder: (context, state) => const HomeScreen(),
26 ),
27 GoRoute(
28 path: '/product/:id',
29 builder: (context, state) {
30 final id = state.pathParameters['id']!;
31 return ProductDetailScreen(productId: id);
32 },
33 ),
34 ],
35);
36
37// Navigate: context.go('/product/123');

💡 Android & iOS Setup for Deep Links

For Android, add intent-filters in AndroidManifest.xml. For iOS, configure Associated Domains in Xcode. The go_router package simplifies deep link handling significantly.

Permission UX Strategy

Permission flows should be staged and contextual:

  • Ask only when user attempts a feature that needs that permission.
  • Explain why the permission is needed before system dialog appears.
  • Provide alternative flows when permission is denied.
  • Persist rationale state so users are not repeatedly nagged.

Context-aware permission UX improves grant rates and reduces drop-off.

  • Deep links validate path and query parameters before navigation.
  • Invalid links route to safe fallback screens with clear messaging.
  • Permission-denied and permanently-denied states have distinct UX handling.
  • Critical entry links are tested from cold start and warm start states.
  • Analytics track permission drop-off and deep link conversion outcomes.

This Lesson In Simple Words

Handle runtime permissions and deep link navigation. Navigation manages how users move between screens and return to previous states.

Your level focus

Think in architecture, reliability, and team-level maintainability.

One practical habit

Design route names and arguments before wiring screen UI.

Deep Understanding Guide

Why this lesson matters

Poor routing decisions create confusing UX and fragile deep-link behavior.

Study flow for better retention

  1. Separate UI, state, and data boundaries before writing implementation details.
  2. Think user journey first: open app, enter data, recover state, continue flow.
  3. If another developer can read your flow quickly, your design choices are clear.

Common Mistakes To Avoid

  • Passing very large objects through routes instead of IDs or lightweight models.
  • Mixing unrelated navigation methods in the same feature.
  • Losing state on back navigation due to poor route stack handling.
  • Not testing deep links and cold-start navigation paths.

Practice Sprint (15-25 Minutes)

  • Before running sample code, predict output and behavior in one sentence.
  • Implement a three-screen flow with named routes and typed arguments.
  • Add one deep-link path and verify expected destination.
  • Write a small route guard for authenticated vs guest users.
  • Complete the required exercises without using hints on the first attempt.
  • Answer this question out loud before checking quiz options: "What should you do when a permission is permanently denied?".

Quick Glossary

  • state: Data that can change and update what the user sees.
  • context: A handle to widget location and inherited data in the tree.
  • route: A screen entry managed by the Navigator.

Code Comprehension Drill

  • State the purpose of the code block in one line before reading details.
  • Mark inputs, state changes, and final output.
  • Change one small value and predict what should happen before running.
  • Run again and compare your prediction with actual behavior.

Architecture Lens

Centralized route strategy reduces hidden coupling between features and screens.

As your app grows, keep UI, state, and data responsibilities separate so each part stays testable and easier to modify.

Lesson Completion Checklist

  • I can explain "Permissions & Deep Linking" in simple words without reading notes.
  • I can describe one real app situation where this concept is required.
  • I know at least one mistake to avoid: Passing very large objects through routes instead of IDs or lightweight models.
  • I can modify one code sample and correctly predict the behavior change.
  • I can finish required exercises with understanding, not trial-and-error guesses.

Frequently Asked Questions

What should you do when a permission is permanently denied?

When a permission is permanently denied, the system will not show the permission dialog again. You must guide the user to the app settings screen where they can enable it manually.

Which package is recommended for deep linking and routing?

go_router is the officially recommended routing package that supports deep linking, path parameters, and web URLs.

How do you request multiple permissions at once?

Create a list of Permission objects and call .request() on the list to batch-request multiple permissions.

Suggest Improvement

Something seems incorrect, unclear, or missing? Let us know.

About The Author

FlutterCraft editorial lessons are reviewed by experienced Flutter developers and updated to stay aligned with modern Flutter and Dart best practices.

Reference docs: Flutter Documentation, Dart Language Tour, and official package documentation where relevant.

Sign in to continue with exercises and quiz for this lesson.

Sign In to Continue