Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter How to add java code to flutter module

Tags:

java

flutter

I want to add some java code to flutter module。Which directory should I add java code. I have tried to add java code in the directory as picture bottom,but the code will not be compiled to aar. enter image description here

like image 932
chefish Avatar asked May 24 '26 15:05

chefish


1 Answers

Basically, what you want is impossible from the pure Flutter module perspective because it uses autogenerated .android and .ios folders and ignores ones without dot. You can change those autogenerated files, but they will be rewritten with the new generation every time.

You have options:

  1. Create a script that automatically adds all the needed stuff to the generated files every time after generation
  2. Create an elaborate scheme with a native wrapper module for the flutter module and its means of communication inside with an exposed native(java, kotlin) interface to the main app. Some replacement of the autogenerated code and even flutter tools will still be required. More info here
like image 141
Pavlo Ostasha Avatar answered May 27 '26 03:05

Pavlo Ostasha



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!