Questions tagged [flutter-platform-channel]

99 questions
17
votes
6 answers

Flutter Project: MainActivity.java is missing

I am trying to create a Platform Channel in a Flutter project to access Android-specific java code. I am creating a new Flutter Application project in Android Studio and following this tutorial which mentions: 1- Navigate to the directory holding…
HemOdd
  • 697
  • 1
  • 7
  • 23
13
votes
5 answers

Read shared preferences in Flutter app that were previously stored in a native app

I have the following problem: right now there is an app in the PlayStore that is written in native code (both iOS and Android) which I'm planning on migrating to flutter. My aim is that the users don't notice there were changes under the hood but…
12
votes
5 answers

Get activity reference in flutter plugin

When I created a flutter plugin, there are two methods in the plugin class by default: override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) and fun registerWith(registrar: Registrar) The comment on the file…
Neeraj
  • 2,376
  • 2
  • 24
  • 41
8
votes
2 answers

Finish FlutterActivity from Flutter when integrating Flutter to native host app [Add2App]

When integrating Flutter to a host app (docs) there is a few ways to do it, one of them (simplest) is open Flutter in a new Activity via FlutterActivity class. Like this: // Java hostActivity.startActivity( …
nail
  • 715
  • 7
  • 20
5
votes
1 answer

Difference between FlutterError.onError and PlatformDispatcher.instance.onError in Flutter

Let's say in a Flutter app we want to catch any uncaught exceptions/errors at the top level, so we do this as per the docs: main() { // All uncaught errors thrown from synchronous code blocks will end up here: FlutterError.onError =…
Nerdy Bunz
  • 6,040
  • 10
  • 41
  • 100
5
votes
1 answer

Flutter plugin that uses .aar modules builds and runs fine in the example app but fails to build in a different app

I've written a Flutter plugin to use an SDK that requires the inclusion of some .aar modules. It builds and runs perfectly in the example app for the plugin, but when I import the plugin in a different app and try to build it, the build immediately…
GroovinChip
  • 339
  • 4
  • 17
5
votes
1 answer

Flutter: Hot reload and hot restart are not working on android after adding firebase background functionality

Hot reload and restart are not working on Android after adding firebase messaging to the app. Getting this error: Hot Reload Error reloadSources: (105) Isolate must be runnable Isolate must berunnable before this request is made On iOS they are…
krishnakumarcn
  • 3,959
  • 6
  • 39
  • 69
5
votes
2 answers

invalid item 'Flutter for Android' in the dependencies list

I want to add native android library in my flutter project, I am trying to perform platform channelling but Flutter Activity is not getting imported in my android code, I founded out that it may be because of this as this is showing as a problem, I…
5
votes
3 answers

Send Map/JSON from Flutter to Android through Method channel

I've set up a basic method channel in Dart and Kotlin Dart Code Future _updateProfile() async { try { var result = await platform.invokeMethod('updateProfile'); print(result); } on PlatformException catch (e) { …
SowingFiber
  • 1,194
  • 1
  • 12
  • 32
5
votes
0 answers

EditText not showing keyboard when tapped in Flutter AndroidView

import android.content.Context; import android.view.View; import android.widget.EditText; import io.flutter.plugin.common.MethodCall; import io.flutter.plugin.common.MethodChannel; import static io.flutter.plugin.common.MethodChannel.Result; import…
4
votes
1 answer

Unable to return value via Platform Channel when using Swift Callback Handlers

I am working with Flutter and Swift. I'm trying to authorize a credit card using the AuthrizeNet SDK, which unfortunately, does not natively support Flutter. To get around this, I created a Platform Channel in my iOS AppDelegate, which I…
Noah H
  • 93
  • 2
  • 9
4
votes
0 answers

Flutter plugin java.lang.NoClassDefFoundError: Failed resolution of error for aar library

I have created a plugin which is just a wrapper around native sdk for android and ios. For Android I have aar file which I have imported in the plugin . I can access the sdk class in the plugin file in the IDE, But when I run the example app of the…
4
votes
1 answer

Flutter: How to wait for android platform channel function to complete and return the result

Creating a platform channel on Android for File upload using AWS SDK. Now I want to wait for the upload to complete in the background and return the status of the result. MethodChannel(flutterEngine.dartExecutor.binaryMessenger,…
krishnakumarcn
  • 3,959
  • 6
  • 39
  • 69
4
votes
2 answers

Calling a function and passing arguments from Kotlin to Flutter

I am dealing with PlatformChannels trying to communicate from Kotlin to Flutter. Trying actually to do what it is explained on the docs from flutter platform channels, but on the opposite direction: flutter platfor channels docs The idea is to call…
codeKiller
  • 5,493
  • 17
  • 60
  • 115
4
votes
1 answer

Flutter both directions of platform channel call?

According to current documentation of flutter platfrom channel it seems only possible to call host (Native) from client (Dart) and then we get response from host. Is there any possiblity of its reverse, e.g. to call directly Client from host?
Shahzad Akram
  • 4,586
  • 6
  • 32
  • 65
1
2 3 4 5 6 7