【问题标题】:Flutter plugin for Developer page in Play StorePlay 商店中开发者页面的 Flutter 插件
【发布时间】:2021-02-18 07:11:43
【问题描述】:

我正在使用 Flutter 开发一个应用程序,我想给用户一个选项来查看我在 Play 商店中提供的所有其他应用程序。我曾经使用以下原生 android 代码做同样的事情:

startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/developer?id=<Developer_ID>")));

有谁知道我可以使用的任何颤振插件。或者我可以使用的任何颤振示例代码。

注意:我希望它在 Play 商店中打开,而不是在浏览器中。

【问题讨论】:

    标签: android flutter dart


    【解决方案1】:

    您必须使用url_launcher 包来启动 AppStore/PlayStore,如下所示:

    import 'package:flutter/material.dart';
    import 'package:url_launcher/url_launcher.dart';
    
    void main() {
      runApp(Scaffold(
        body: Center(
          child: RaisedButton(
            onPressed: _launchDeveloperPage,
            child: Text('Show All Apps'),
          ),
        ),
      ));
    }
    
    _launchDeveloperPage() async {
      const url = 'https://play.google.com/store/apps/developer?id=<Developer_ID>';
      if (await canLaunch(url)) {
        await launch(url);
      } else {
        throw 'Could not launch $url';
      }
    }
    

    【讨论】:

      【解决方案2】:

      您可以使用url_launcher

      此示例将尝试直接启动 Play 商店并仅在未安装 Play 商店应用时打开浏览器:

        void _launchDeveloperPage() async {
          final devID = '<DEV_ID>';
          final market = 'market://dev?id=$devID';
          final url = 'https://play.google.com/store/apps/developer?id=$devID';
          if (await canLaunch(market)) {
            await launch(market);
          } else if (await canLaunch(url)) {
            await launch(url);
          } else {
            throw 'Could not launch $url';
          }
        }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-07-29
        • 2020-05-15
        • 1970-01-01
        • 2022-12-30
        相关资源
        最近更新 更多