HtmlEditor class

HTML file injection helper for CLI commands.

Provides pure string-based utilities for reading and modifying HTML files (e.g. web/index.html) without external parser packages.

Usage

// Read raw HTML
final html = HtmlEditor.read('/path/to/index.html');

// Inject a script tag before </head> (guard with hasContent first)
if (!HtmlEditor.hasContent('/path/to/index.html', 'OneSignalSDK')) {
  HtmlEditor.injectBeforeClose(
    '/path/to/index.html',
    '</head>',
    '  <script src="sdk.js" defer></script>',
  );
}

// Add a <meta> tag (idempotent)
HtmlEditor.addMetaTag('/path/to/index.html', {
  'name': 'description',
  'content': 'My Flutter App',
});

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

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

Static Methods

addMetaTag(String path, Map<String, String> attributes) → void
Add a <meta> tag before </head>, building it from attributes.
hasContent(String path, String pattern) → bool
Check whether pattern appears in the HTML file (case-insensitive).
injectBeforeClose(String path, String closingTag, String content) → void
Inject content immediately before closingTag in the HTML file.
read(String path) → String
Read the raw HTML content from path.