Go-flutter: New Plugin: uni_links

Created on 23 Aug 2019  路  15Comments  路  Source: go-flutter-desktop/go-flutter

Hi,
I will probably need to use uni_links soon-ish. That will probably require some research, so I just wanted to create this issue to collect any info I can find.

plugin wontfix

Most helpful comment

Is possible to pass arguments from go app to dart main function?

No and you should avoid putting business code above runAp because it delays the first frame.

For needs described above you can use the following system channel: https://api.flutter.dev/flutter/services/SystemChannels/navigation-constant.html

pushRoute, which is called with a single string argument when the operating system instructs the application to open a particular page.

You can make a go-flutter plugin that invoke this method https://github.com/go-flutter-desktop/go-flutter/wiki/Implement-a-plugin#call-dart-from-golang


Edit add simple example:
Golang:

channel := plugin.NewMethodChannel(p.messenger, "flutter/navigation", plugin.JSONMethodCodec{})
channel.InvokeMethod("pushRoute", "/anotherRoute")

Dart:

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      routes: <String, WidgetBuilder>{
        '/anotherRoute': (BuildContext context) =>
            Scaffold(body: Text("anotherRoute")),
        //other routes
      },
      home: Scaffold(body: Text("Home")),
    );
  }
}

All 15 comments

Is possible to pass arguments from go app to dart main function?

Is possible to pass arguments from go app to dart main function?

No and you should avoid putting business code above runAp because it delays the first frame.

For needs described above you can use the following system channel: https://api.flutter.dev/flutter/services/SystemChannels/navigation-constant.html

pushRoute, which is called with a single string argument when the operating system instructs the application to open a particular page.

You can make a go-flutter plugin that invoke this method https://github.com/go-flutter-desktop/go-flutter/wiki/Implement-a-plugin#call-dart-from-golang


Edit add simple example:
Golang:

channel := plugin.NewMethodChannel(p.messenger, "flutter/navigation", plugin.JSONMethodCodec{})
channel.InvokeMethod("pushRoute", "/anotherRoute")

Dart:

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      routes: <String, WidgetBuilder>{
        '/anotherRoute': (BuildContext context) =>
            Scaffold(body: Text("anotherRoute")),
        //other routes
      },
      home: Scaffold(body: Text("Home")),
    );
  }
}

While we have the exper present: from my understanding Windows would spawn
a new process every time an uni link is opened. I think this process then
needs to start the actual app (if needed) and deliver the message. Is that
understanding correct? Is there any standard way for inter process
commutation in go?

I think this process then needs to start the actual app (if needed) and deliver the message. Is that
understanding correct?

I'm not an expert, but I does match my browser behavior, when I click on a link in the terminal either my browser is started with the link, or a new tab is opened.

Is there any standard way for inter process commutation in go?

again, not a big expert in that domain.
There is https://github.com/ybbus/jsonrpc , without much search that what I would use^^

I thinks this is a relevent kink:
https://github.com/w3c/web-share/blob/master/docs/native.md

Its a good heads up for how we can implement sharing native.

any news on this? I'm willing to use move my app to go-flutter but lack the necessary knowledge to implement it myself.
I implemented uni_links for macos on the FDE side if it helps somehow
https://github.com/LittleLightForDestiny/littlelight/tree/desktop/desktop_plugins/uni_links_fde/macos

You could re-use your MacOS implementation to create a CGO plugin, but that still requires the knowledge of go and go-flutter plugins.

is there some knowledge base or a quickstart for plugins ?
I was stuck while trying to create a minimal example to proper "test" my plugin.
Also, is there already a repo for this plugin ? Or should I create a new one ?

Here are the official go-flutter plugins: https://github.com/go-flutter-desktop/plugins
For the repo you can just upload it to your own account.

is there some knowledge base or a quickstart for plugins ?
I was stuck while trying to create a minimal example to proper "test" my plugin.

Yes, sure, checkout our wiki:
https://github.com/go-flutter-desktop/go-flutter/wiki/Plugin-info
https://github.com/go-flutter-desktop/go-flutter/wiki/Create-a-hover-compatible-plugin
https://github.com/go-flutter-desktop/go-flutter/wiki/Implement-a-plugin

The problem on implementing it for linux is that only the .desktop file can specify a custom protocol handler

So aside from the code part, there will also be need to change something during packaging? Perhaps this can be related to the hooks discussion?

@GeertJohan probably. In macOS i need to change the Info.plist to add the url schemes. Also the way go-flutter runs its dev builds on mac doesn't support that (it isn't a packaged .app) so it could be a bit hard to test this kind of feature.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Fireprufe15 picture Fireprufe15  路  6Comments

Tokenyet picture Tokenyet  路  7Comments

GeertJohan picture GeertJohan  路  4Comments

pauldemarco picture pauldemarco  路  7Comments

atresnjo picture atresnjo  路  4Comments