Navigate in cached Flutter Engine

1.4k Views Asked by At

I have a question regarding FlutterEngine I have a single cached flutter engine that I wanna reuse on many screens in my android app, so I'd have to somehow navigate the routes inside cached engine.

Is there any way I can set the route of cached engine before starting the flutter activity?

Thankyou.

1

There are 1 best solutions below

1
On

After some research and diving into documentation, I found out that flutter engine provides a NavigationChannel that can be used to push/pop routes into an engine

Example, if you want to push a route:

FlutterEngine engine = FlutterEngineCache.getInstance().get("MyFlutterEngine");
if (engine != null) {
    engine.getNavigationChannel().pushRoute("/myRoute2");
}