Is it possible to do something like this:
flutter build apk --enable-software-rendering
I need a release version that performs the say way as:
flutter run --enable-software-rendering --profile
Thank you.
Is it possible to do something like this:
flutter build apk --enable-software-rendering
I need a release version that performs the say way as:
flutter run --enable-software-rendering --profile
Thank you.
TL;DR Put getIntent().putExtra("enable-software-rendering", true);
on top of your onCreate()
Note - I assumed Android from the "apk" in question title and the need for software rendering.
Looking at the source code, the --enable-software-rendering
flag for flutter run
causes the activity to be launched using am start
with --ez enable-software-rendering true
, which puts that as a boolean extra into the intent.
If you wish to control when to use software rendering from code (such as depending on API level or device model), set the mentioned intent extra early in your onCreate()
.
Full Example:
import android.os.Bundle;
import io.flutter.facade.Flutter;
import io.flutter.app.FlutterActivity;
public class MyActivity extends FlutterActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
// use software rendering (ideally only when you need to)
getIntent().putExtra("enable-software-rendering", true);
// start Flutter
Flutter.startInitialization(this);
super.onCreate(savedInstanceState);
}
}