bitcaptcha_flutter library

星辉数盾人机验证 BitCaptcha 的 Flutter 组件:智能无感知 BitCaptchaSense、滑动拼图 BitCaptcha、 文字 / 图标点选 BitCaptchaText,以及弹窗式 showBitCaptcha / showBitCaptchaText

BitCaptcha(
  captchaId: 'your-captcha-id',
  apiBase: 'https://shudun.bitbeam.cn',
  onVerify: (r) => login(captcha: r.validate),   // validate 交给业务后端核销
)
// 或弹窗,用户关闭返回 null
final r = await showBitCaptcha(context, captchaId: '...', apiBase: '...');

Classes

BitCaptcha
Inline slide puzzle. Height = width / 2 + 12 + the slider bar.
BitCaptchaChallenge
A slide puzzle challenge: two images plus motion parameters. Geometry is in logical pixels (320×160); the images are 2×.
BitCaptchaCheckResult
Outcome of a check: success with the validate ticket, or a failure code.
BitCaptchaClient
Low-level API client used by the widgets: fetches challenges, submits encrypted answers, runs the invisible check. Pass your own instance to a widget to share it or inject an http.Client.
BitCaptchaResult
What a pass hands to your backend. validate is a one-time ticket valid for 180 seconds.
BitCaptchaSense
Smart invisible check: one tap. Trusted users pass right away; suspicious requests get a slide puzzle or text click inside the same widget. Nothing else to wire up.
BitCaptchaSenseResult
Outcome of the invisible check: pass with validate, or a fallback challenge (slider / textclick).
BitCaptchaStrings
Built-in UI strings. lang: 'auto' follows the system locale; override any key with the widgets' i18n.
BitCaptchaText
Inline text click / icon click. Tap the characters or icons in the order shown; icon picks the icon variant.
BitCaptchaTextChallenge
A text / icon click challenge: a background plus ordered targets. Positions stay on the server; the client only gets targets and canvas size.
BitCaptchaTheme
Widget colors. The default is a light theme; BitCaptchaTheme.dark suits dark surfaces.

Functions

showBitCaptcha(BuildContext context, {required String captchaId, required String apiBase, double width = 320, bool fluid = true, double minWidth = 280, double maxWidth = 400, String lang = 'auto', Map<String, String>? i18n, BitCaptchaTheme theme = const BitCaptchaTheme(), String? title, BitCaptchaClient? client}) Future<BitCaptchaResult?>
Slide puzzle in a dialog. Resolves with the BitCaptchaResult, or null when the user closes it.
showBitCaptchaText(BuildContext context, {required String captchaId, required String apiBase, bool enhanced = true, bool icon = false, double width = 320, bool fluid = true, double minWidth = 280, double maxWidth = 400, String lang = 'auto', Map<String, String>? i18n, BitCaptchaTheme theme = const BitCaptchaTheme(), String? title, BitCaptchaClient? client}) Future<BitCaptchaResult?>
Text click / icon click in a dialog. Resolves with the BitCaptchaResult, or null when the user closes it.

Exceptions / Errors

BitCaptchaException
Thrown by BitCaptchaClient and passed to onError. code tells the family, retryAfter the wait on rate limits.