My goal is to theme a flutter web app from an api call instead building separate apps per client. This api call would return a favicon, app name, colors, etc, and then display these in a flutter web app. I'm struggling to find a good way to accomplish this.
In theory I could make a javascript call from the index.html file before the flutter engine loads, then update the title, favicon, and loading/splash screen, and finally pass this data into the flutter engine somehow so that the flutter app can continue to use this data. I can't find a way to pass in the data into the engine initialization code. This would potentially slow down the startup time, but would be ok.
Another potential solution would be to show generic colors/no icon until the flutter engine has loaded, and then update all of these. But everything I see is that the favicon has to be set at the beginning, either in the html or manifest. If I could update these later, this would be a good solution.
I'm trying to avoid making the api call in javascript to update the html assets at the start, and then making the call again after flutter loads, to get the data again to theme the flutter assets.
Does anyone know how to solve any of these problem, or have another idea?
I've come up with a workable solution.
First update your assets in index.html that aren't white labeled, leaving stubs in their place that we'll fill in later. i.e.
<title></title>
<link rel="icon" id="favicon">
Next show a nice loading indicator while flutter loads. To do this, just put the html for it in the body element of the index.html file.
Finally update the webpage title and favicon using javascript inside Flutter. We used package
universal_html: 2.0.8
https://pub.dev/packages/universal_html
then you can update the favicon
import 'package:universal_html/html.dart';
var favicon = document.getElementById('favicon');
favicon?.setAttribute('href','insertLinkToYourImage');
Updating the title can be accomplished in various normal ways like just setting the title attribute of a MaterialApp widget.