小编M A*_* Al的帖子

类“FirebaseMessaging”没有默认构造函数 Flutter 2

在切换到 Flutter 2 之前,我使用旧版本的 firebaseMessaging 没有问题,现在我有了最新版本。升级后出现以下错误:

The class 'FirebaseMessaging' doesn't have a default constructor.


Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

和:

The method 'configure' isn't defined for the type 'FirebaseMessaging'.


Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

全班:


class ShowNotifications {
static final FirebaseMessaging firebaseMessaging = FirebaseMessaging();
 static FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
  new FlutterLocalNotificationsPlugin();

  static void initialization(){
    var initializationSettingsAndroid =
    new AndroidInitializationSettings('@mipmap/ic_launcher');
    var initializationSettingsIOS = new IOSInitializationSettings();
    var initializationSettings = new InitializationSettings(
        android: initializationSettingsAndroid, iOS: initializationSettingsIOS);

    flutterLocalNotificationsPlugin = new FlutterLocalNotificationsPlugin();
    flutterLocalNotificationsPlugin.initialize(initializationSettings,
        onSelectNotification: onSelectNotification);
  }




 static void showNotification(String title, String body) async {
    await _demoNotification(title, …
Run Code Online (Sandbox Code Playgroud)

flutter firebase-cloud-messaging flutter2.0

5
推荐指数
1
解决办法
4983
查看次数

如何将 flutter 应用程序中的图像文件共享到其他应用程序

我有一个应用程序,该应用程序向用户显示一张图像。该图像我将其作为链接保存在 MySQL 数据库中,并将图像保存在服务器文件夹中。现在我尝试让用户可以从我的应用程序将该图像分享到其他应用程序,例如 WhatsApp 或 Facebook。

我使用 share_plus 3.0.5 包来实现:

分享加3.0.5

  await Share.shareFiles([//////////////////here/////////////], text: 'Image Shared');
Run Code Online (Sandbox Code Playgroud)

通过此代码获取图像:

  Future MakeShare() async {
var response = await http.get(
    Uri.parse("https://*********/ImageMakeShare.php?ID=" + widget.IDS.toString()),
    headers: {"Accept": "application/json"});

setState(() {

  var convertDataToJson = json.decode(response.body);
  dataImage = convertDataToJson['result'];
  if (dataImage != null) {

    imageMaine = dataImage[0]['image'];

}}); }
Run Code Online (Sandbox Code Playgroud)

我试着让它像那样

  await Share.shareFiles([imageMaine ], text: 'Image Shared');
Run Code Online (Sandbox Code Playgroud)

但我收到错误:

E/flutter (10763): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: PlatformException(https:/*******0ee2e.png (No such file or directory), null, null, null)
Run Code Online (Sandbox Code Playgroud)

现在我需要知道如何让用户可以将该图像共享到其他应用程序。

有人可以帮助我吗?

flutter

4
推荐指数
1
解决办法
1万
查看次数