Closed BedRockGx closed 4 years ago
Same error for me. I think the documentation ins't clear
看看示例代码
AndroidManifest.xml => <application android:name=".MyApplication" android:label="kuaichuan" android:usesCleartextTraffic="true" android:icon="@mipmap/ic_launcher"> <activity android:name=".MainActivity"
add MyApplication.java
MyApplication.java =>
package xxx.xxxxxx;
import io.flutter.app.FlutterApplication; import io.flutter.plugin.common.PluginRegistry; import io.flutter.plugins.GeneratedPluginRegistrant; import vn.hunghd.flutterdownloader.FlutterDownloaderPlugin;
public class MyApplication extends FlutterApplication implements PluginRegistry.PluginRegistrantCallback { @Override public void registerWith(PluginRegistry registry) { GeneratedPluginRegistrant.registerWith(registry); // FlutterDownloaderPlugin.registerWith(registry.registrarFor("vn.hunghd.flutterdownloader.FlutterDownloaderPlugin")); } }
but it not work,always is this question.
E/flutter (22756): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: 'package:flutter_downloader/src/downloader.dart': Failed assertion: line 388 pos 12: 'callbackHandle != null': callback must be a top-level or a static function
E/flutter (22756): #0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:40:39)
E/flutter (22756): #1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:36:5)
E/flutter (22756): #2 FlutterDownloader.registerCallback (package:flutter_downloader/src/downloader.dart:388:12)
E/flutter (22756): #3 _FPIndexPageState.executeDownload (package:fast_pass/app/pages/home/fp_index_page.dart:628:23)
E/flutter (22756):
why?
APP flash back!!!
Unhandled Exception: 'package:flutter_downloader/src/downloader.dart': Failed assertion: line 388 pos 12: 'callbackHandle != null': callback must be a top-level or a static function
==> Solucation
Future
final platform = _localNotifications.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>();
await platform?.createNotificationChannel(_andriodChannel);
}
APP flash back!!!
Unhandled Exception: 'package:flutter_downloader/src/downloader.dart': Failed assertion: line 388 pos 12: 'callbackHandle != null': callback must be a top-level or a static function
==> Solucation
Future
final platform = _localNotifications.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>();
await platform?.createNotificationChannel(_andriodChannel);
}
APP flash back!!!
Unhandled Exception: 'package:flutter_downloader/src/downloader.dart': Failed assertion: line 388 pos 12: 'callbackHandle != null': callback must be a top-level or a static function