HtmlShellGenerator class
Generates static HTML shell files for each route.
These HTML shells contain proper meta tags and structured data that crawlers can read before Flutter loads. This is a build-time tool, not a runtime tool.
final generator = HtmlShellGenerator(
baseUrl: 'https://myapp.com',
templatePath: 'web/index.html',
);
generator.addPage(
path: '/',
title: 'Home | My App',
description: 'Welcome to My App',
ogImage: 'https://myapp.com/og-home.png',
);
generator.addPage(
path: '/about',
title: 'About | My App',
description: 'Learn about us',
);
final shells = generator.generate();
// shells is a Map<String, String> of path -> html content
Constructors
- HtmlShellGenerator({required String baseUrl, String? baseTemplate})
Properties
- baseTemplate → String?
-
final
- baseUrl → String
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addPage(
{required String path, required String title, String? description, String? ogImage, String? ogType, String? canonicalUrl, String? jsonLd, String? noscriptContent, Map< String, String> ? additionalMeta}) → void - Add a page to generate a shell for
-
generate(
) → Map< String, String> - Generate HTML shells for all added pages
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited