Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use Java or Kotlin code in Flutter?

I was wondering if (since I can use Obj-C code in Swift using the proper manners) can I use Java or Kotlin in Flutter apps?

Like import a plugin or framework or just create a function or method using another language and expose it to Dart/Flutter.

like image 446
Fernando Rocha Avatar asked Jul 24 '26 06:07

Fernando Rocha


2 Answers

You can always use platform channels. https://flutter.dev/docs/development/platform-integration/platform-channels

like image 155
Pedro R. Avatar answered Jul 26 '26 21:07

Pedro R.


Flutter's Main Language: Flutter primarily uses a language called Dart. Think of Dart as the main builder of your Flutter app.

Java and Kotlin as Helpers: You can't directly use Java or Kotlin to build your entire Flutter app. However, they can lend Flutter a hand with special tasks.

How They Help:

  • Phone Calls: Imagine you want your Flutter app to make a call. Flutter can ask Java or Kotlin (who know how to work the Android phone features) to do this.

  • Fancy Camera Tricks: Flutter might need Java or Kotlin's help if you want to do advanced things with your phone's camera.

Plugins: Sometimes, Java or Kotlin code is already bundled into handy packages called "plugins" that you can plug into your Flutter app to do cool things.

Important: Use Flutter and Dart as much as possible. Think of Java and Kotlin as backup helpers for special occasions when Flutter needs their specific skills.

And check this: https://flutter.dev/docs/development/platform-integration/platform-channels

like image 23
Arjun M Avatar answered Jul 26 '26 20:07

Arjun M