BotDetector class
Detects crawlers and preview bots by their User-Agent header.
const detector = BotDetector();
detector.isBot('Googlebot/2.1 (+http://www.google.com/bot.html)'); // true
detector.isBot('Mozilla/5.0 ... Chrome/126.0 Safari/537.36'); // false
Constructors
-
BotDetector({List<
String> extraPatterns = const []}) -
Uses defaultPatterns, optionally extended with
extraPatterns.const -
BotDetector.only(List<
String> patterns) -
Uses only
patternsand ignores defaultPatterns completely.const
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
-
isBot(
String? userAgent) → bool -
Whether
userAgentbelongs to a known crawler. -
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
Constants
-
defaultPatterns
→ const List<
String> - Lower-case User-Agent fragments of the crawlers that matter for SEO: search engines, social-media link previews and AI crawlers, plus a few generic markers.