webify_toolkit 0.1.0
webify_toolkit: ^0.1.0 copied to clipboard
Flutter Web SEO Toolkit — Meta tags, structured data (JSON-LD), sitemap generation, social preview cards, and analytics integration. Make your Flutter Web app visible to search engines.
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:webify_toolkit/webify.dart';
import 'package:webify_toolkit/webify_web.dart';
import 'pages/about_page.dart';
import 'pages/blog_page.dart';
import 'pages/home_page.dart';
import 'pages/product_detail_page.dart';
import 'pages/product_page.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
Webify.initialize(
config: WebifyConfig(
baseUrl: 'https://webify-example.com',
defaultTitle: 'Webify Example',
titleTemplate: '%s | Webify Example',
defaultDescription:
'Demo app showing Flutter Web SEO with the webify package',
defaultOgImage: 'https://webify-example.com/og-default.png',
twitterSite: '@webify_flutter',
locale: 'en_US',
defaultOrganization: const OrganizationSchema(
name: 'Webify Example Co.',
url: 'https://webify-example.com',
logo: 'https://webify-example.com/logo.png',
sameAs: [
'https://twitter.com/webify_flutter',
'https://github.com/thesanaullah/webify',
],
),
analyticsProviders: [
CustomProvider(
providerName: 'console',
onInitialize: () => debugPrint('[Analytics] Initialized'),
onPageView: (path, title, params) =>
debugPrint('[Analytics] Page view: $path ($title)'),
onEvent: (name, params) =>
debugPrint('[Analytics] Event: $name $params'),
),
],
enableNoscriptFallback: true,
debugMode: kDebugMode,
),
);
runApp(const WebifyExampleApp());
}
class WebifyExampleApp extends StatelessWidget {
const WebifyExampleApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Webify Example',
debugShowCheckedModeBanner: false,
theme: ThemeData(colorSchemeSeed: Colors.blue, useMaterial3: true),
navigatorObservers: [
SeoRouteObserver(
onRouteChanged: (route) {
debugPrint('[Router] Route changed: $route');
},
autoTrackPageViews: false,
),
],
initialRoute: '/',
routes: {
'/': (_) => const HomePage(),
'/products': (_) => const ProductPage(),
'/products/flutter-widget-pro': (_) => const ProductDetailPage(),
'/blog': (_) => const BlogPage(),
'/about': (_) => const AboutPage(),
},
);
}
}