The question you mention above (https://stackoverflow.com/a/70935986) is not working. In the case of React, it does. But, Next.js? Won't. Why? Because Next.js renders twice for client-side and server-side.
So, put your flutter app build inside /public folder. And inside route components on load event, load that application with the below code.
function loadMainDartJs() {
var scriptTag = document.createElement('script');
scriptTag.src = './main.dart.js';
scriptTag.type = 'application/javascript';
document.getElementById('flutterPreview').append(scriptTag);
}
// Should be called on load of client-side render
if (typeof window !== "undefined") loadMainDartJs();
Another good reference to read: https://github.com/vercel/next.js/issues/5354#issuecomment-520305040