intent_launcher 0.1.0 copy "intent_launcher: ^0.1.0" to clipboard
intent_launcher: ^0.1.0 copied to clipboard

PlatformAndroid

Provides a way to launch Android intents, e.g. opening a specific activity.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:intent_launcher/intent_launcher.dart';

void main() {
  runApp(const Root());
}

class Root extends StatelessWidget {
  const Root({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Intent Launcher Example'),
        ),
        body: const IntentLauncherTest(),
      ),
    );
  }
}

class IntentLauncherTest extends StatelessWidget {
  const IntentLauncherTest({super.key});

  Future<void> _startActivityAsync({
    required BuildContext context,
    required String action,
    IntentLauncherParams params = const IntentLauncherParams(),
  }) async {
    final result = await startActivityAsync(
      action,
      params: params,
    );

    if (!context.mounted) return;
    debugPrint(result.toString());
  }

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Column(
        children: [
          ElevatedButton(
            onPressed: () {
              _startActivityAsync(
                context: context,
                action: ActivityAction.wirelessSettings,
                params: const IntentLauncherParams(),
              );
            },
            child: const Text('Wireless Settings'),
          ),
          ElevatedButton(
            onPressed: () {
              _startActivityAsync(
                context: context,
                action: ActivityAction.settings,
                params: const IntentLauncherParams(),
              );
            },
            child: const Text('Settings'),
          ),
          ElevatedButton(
            onPressed: () {
              _startActivityAsync(
                context: context,
                action: ActivityAction.applicationDetailsSettings,
                params: const IntentLauncherParams(
                  data: 'package:com.android.vending',
                ),
              );
            },
            child: const Text('Application Details for Play Store'),
          ),
          ElevatedButton(
            onPressed: () {
              _startActivityAsync(
                context: context,
                action: ActivityAction.applicationDetailsSettings,
                params: const IntentLauncherParams(
                  data: 'package:package.name.that.doesnt.exist',
                ),
              );
            },
            child: const Text('Application Details for not existing package'),
          ),
          ElevatedButton(
            onPressed: () {
              _startActivityAsync(
                context: context,
                action: 'android.media.action.IMAGE_CAPTURE',
                params: const IntentLauncherParams(
                  flags: 100,
                ),
              );
            },
            child: const Text('Camera'),
          ),
        ],
      ),
    );
  }
}
1
likes
150
points
152
downloads

Publisher

unverified uploader

Weekly Downloads

Provides a way to launch Android intents, e.g. opening a specific activity.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on intent_launcher