linker 0.0.2

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • new59

linker

A flutter plugin to link with other app or system function.

Getting Started

add


linker: 0.0.2

to your pubspec.yaml, and run flutter packages get

Usage

Android

Use action

try {
  ActivityResult result = await Linker.startActivityForResult(
      new Intent.fromAction("android.settings.SETTINGS"), 0);
  print(result);
} on PlatformException catch (e) {
  print("Open failed $e");
}

Open google map

try {
  await Linker.startActivity(new Intent.fromAction(
    "android.intent.action.VIEW",
    uri: Uri.parse(
        "http://ditu.google.cn/maps?hl=zh&mrt=loc&q=31.1198723,121.1099877(上海青浦大街100号)"),
  ));
} on PlatformException catch (e) {
  print("Open failed $e");
}

ios

Open wechat

 try {
 await Linker.openURL("weixin://");
} on PlatformException catch (e) {
  print("Open failed $e");
}

Open Settings

try {
  await Linker.openURL("App-Prefs:root");
} on PlatformException catch (e) {
  print("Open failed $e");
}

Call 10086

 try {
  await Linker.openURL("tel:10086");
} on PlatformException catch (e) {
  print("Open failed $e");
}

0.0.2

* support Intent.ACTION_VIEW in android
* add open qq/wechat in android

0.0.1

* ios canOpenURL
* ios openURL
* android startActivityForResult
* android startActivity

example/lib/main.dart

import 'dart:io';

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

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

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

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

class Button extends StatelessWidget {
  final String label;

  final VoidCallback onPressed;

  Button({this.label, this.onPressed});

  @override
  Widget build(BuildContext context) {
    return new RaisedButton(
        onPressed: onPressed,
        color: Colors.blueAccent,
        textColor: Colors.white,
        child: new Text(label));
  }
}

class AndroidExample extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new Center(
      child: new Column(
        mainAxisSize: MainAxisSize.min,
        children: <Widget>[
          new Button(
              onPressed: () async {
                try {
                  await Linker.openSetting();
                } on PlatformException catch (e) {
                  print("Open failed $e");
                }
              },
              label: "Open Settings"),
          new Button(
              onPressed: () async {
                try {
                  await Linker.startActivity(new Intent.fromAction(Intent.ACTION_VIEW,
                      uri: Uri.parse("mqqwpa://im/chat?chat_type=wpa&uin=123456")));
                } on PlatformException catch (e) {
                  print("Open failed $e");
                }
              },
              label: "Open QQ"),
          new Button(
              onPressed: () async {
                try {
                  await Linker.startActivity(new Intent.callApp( packageName:  "com.tencent.mm",className: "com.tencent.mm.ui.LauncherUI"));
                } on PlatformException catch (e) {
                  print("Open failed $e");
                }
              },
              label: "Open Wechat"),
          new Button(
              onPressed: () async {
                try {
                  await Linker.openNetworkSetting();
                } on PlatformException catch (e) {
                  print("Open failed $e");
                }
              },
              label: "Open Network settings"),
          new Button(
              onPressed: () async {
                try {
                  await Linker.startActivity(new Intent.fromAction(
                    "android.intent.action.VIEW",
                    uri: Uri.parse(
                        "http://ditu.google.cn/maps?hl=zh&mrt=loc&q=31.1198723,121.1099877(上海青浦大街100号)"),
                  ));
                } on PlatformException catch (e) {
                  print("Open failed $e");
                }
              },
              label: "Open google map"),
        ],
      ),
    );
  }
}

class IosExample extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new Center(
      child: new Column(
        mainAxisSize: MainAxisSize.min,
        children: <Widget>[
          new Button(
              onPressed: () async {
                try {
                  await Linker.openURL("weixin://");
                } on PlatformException catch (e) {
                  print("Open failed $e");
                }
              },
              label: "Open Wechat"),
          new Button(
              onPressed: () async {
                try {
                  await Linker.openSetting();
                } on PlatformException catch (e) {
                  print("Open failed $e");
                }
              },
              label: "Open Settings"),
          new Button(
              onPressed: () async {
                try {
                  await Linker.openURL("tel:10086");
                } on PlatformException catch (e) {
                  print("Open failed $e");
                }
              },
              label: "Call 10086"),
        ],
      ),
    );
  }
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Platform.isAndroid ? new AndroidExample() : new IosExample(),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  linker: ^0.0.2

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:linker/linker.dart';
  
Version Uploaded Documentation Archive
0.0.2 Sep 20, 2018 Go to the documentation of linker 0.0.2 Download linker 0.0.2 archive
0.0.1 Sep 6, 2018 Go to the documentation of linker 0.0.1 Download linker 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
29
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
59
Learn more about scoring.

We analyzed this package on Sep 20, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.3
  • Flutter: 0.8.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Suggestions

The description is too short.

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Package is pre-v0.1 release.

While there is nothing inherently wrong with versions of 0.0.*, it usually means that the author is still experimenting with the general direction of the API.

Format lib/linker.dart.

Run flutter format to format lib/linker.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.50.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8