launch_args 2.0.5+1 copy "launch_args: ^2.0.5+1" to clipboard
launch_args: ^2.0.5+1 copied to clipboard

Plugin to get command line launch args for both Android and iOS.

example/lib/main.dart

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

Future<void> main(List<String>? args) async {
  WidgetsFlutterBinding.ensureInitialized();
  args = args?.isNotEmpty == true ? args : (await LaunchArgs.args);

  runApp(MyApp(args: args));
}

class MyApp extends StatelessWidget {
  const MyApp({super.key, this.args});

  final List<String>? args;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Launch Args'),
        ),
        body: ListView(
          children: [
            for (var arg in args ?? <String>['n/a'])
              ListTile(
                title: Text(arg),
              ),
          ],
        ),
      ),
    );
  }
}
1
likes
160
pub points
62%
popularity

Publisher

verified publisherpeifferinnovations.com

Plugin to get command line launch args for both Android and iOS.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, logging

More

Packages that depend on launch_args