Skip to content

Add a capabilities API and never silently drop a requested type #48

Description

@developerjamiu

Support varies by platform and by OS version, so it cannot be a compile-time constant or a table in the README. Today the plugin silently returns fewer spans, which is why "DateTime is not supported on Android" lives in prose.

Keep the surface to one getter:

Set<ItemSpanType> get supportedTypes;

And one hard rule:

Requesting a type the current platform cannot detect throws UnsupportedError naming the type. Not a silent drop, not a logged warning.

// on Windows
await SmartTextFlutter.classifyText(text, types: {ItemSpanType.address});
// throws UnsupportedError: ItemSpanType.address is not supported on this platform.
// Supported: url, email, phone, hashtag, mention

Callers that want graceful degradation intersect with supportedTypes first. Callers that pass nothing keep today's behaviour of detecting everything available.

This is what turns "as many platforms as possible" from a compromise into a feature: the package never pretends.

Found during the v0.4.0 codebase audit.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    apiPublic API shapeenhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions