Skip to main content

android_app_launch_plugin 0.0.2 copy "android_app_launch_plugin: ^0.0.2" to clipboard
android_app_launch_plugin: ^0.0.2 copied to clipboard

A android app launch plugin.

example/lib/main.dart

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

import 'package:flutter/services.dart';
import 'package:android_app_launch_plugin/android_app_launch_plugin.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}



class _MyAppState extends State<MyApp> {

  List<Widget> apps=[];
  @override
  void initState() {
    super.initState();
    initPlatformState();

  }

  void itemOnPressed(String pkg_name){
    Map<String,String> map=new Map();
    map["test"]="123";
    map["test1"]="ddddddddddddd";
    AndroidAppLaunchPlugin.LaunchAppWithExtra(pkg_name,map);
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    List<Widget> apps=new List();
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      //test Init
      AndroidAppLaunchPlugin.Init();

      //test GetApps
      Future<List> out_apps=AndroidAppLaunchPlugin.GetApps();
      out_apps.then((o){
        for(int i=0;i<o.length;i++){
          apps.add(IconButton(
            icon: o[i].ico,
            onPressed: ()=> itemOnPressed(o[i].packageName),
          ));
        }

        setState(() {
          this.apps=apps;
        });
      }).catchError((e){
        print("AndroidAppLaunchPlugin.GetApps:"+e);
        return;
      });
    } on PlatformException {
      return;
    }


    //test GetExtra
    AndroidAppLaunchPlugin.GetExtra("test").then((o){
      print("AndroidAppLaunchPlugin.GetExtra:"+o);
    });

  }

  @override
  Widget build(BuildContext context) {

    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: GridView(
            gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                crossAxisCount: 5,
                mainAxisSpacing: 30,
                childAspectRatio: 3
            ),
            padding: const EdgeInsets.only(left: 10,right: 10,top: 10),
            children: apps,
          ),
        ),
      ),
    );
  }
}
0
likes
25
points
39
downloads

Publisher

unverified uploader

Weekly Downloads

A android app launch plugin.

Homepage

License

MIT (license)

Dependencies

flutter

More

Packages that depend on android_app_launch_plugin

Packages that implement android_app_launch_plugin