initialize static method
Initialize webify with the given configuration.
Must be called once before using any webify features.
Typically called in main() before runApp().
void main() {
WidgetsFlutterBinding.ensureInitialized();
Webify.initialize(
config: WebifyConfig(
baseUrl: 'https://myapp.com',
defaultTitle: 'My App',
titleTemplate: '%s | My App',
analyticsProviders: [GA4Provider(measurementId: 'G-XXX')],
),
);
runApp(MyApp());
}
Implementation
static void initialize({required WebifyConfig config}) {
final webify = Webify._();
webify._platform = createPlatform();
webify._config = config;
_instance = webify;
// Apply defaults
webify._applyDefaults();
// Log in debug mode
if (config.debugMode) {
debugPrint('[webify] Initialized');
debugPrint(
'[webify] Platform: ${webify._platform.isWeb ? "Web" : "Non-Web"}',
);
if (webify._platform.isWeb) {
debugPrint('[webify] Renderer: ${webify._platform.rendererType.name}');
}
}
}