Skip to main content

Flutter Widgets

Pre-built widgets for easy integration.

SimplrForm

Wraps your form to capture touch events:

SimplrForm(
tracker: simplr,
child: Column(
children: [
SimplrTextField(
tracker: simplr,
fieldName: 'email',
controller: _emailController,
),
// More fields...
],
),
)

SimplrTextField

Drop-in replacement for TextField with keystroke tracking:

SimplrTextField(
tracker: simplr,
controller: _controller,
fieldName: 'email',
decoration: InputDecoration(
labelText: 'Email',
hintText: 'Enter your email',
),
keyboardType: TextInputType.emailAddress,
validator: (value) => value!.isEmpty ? 'Required' : null,
)

Properties

PropertyTypeRequiredDescription
trackerSimplrFraudYesSDK instance
fieldNameStringYesField identifier
controllerTextEditingControllerYesText controller
decorationInputDecorationNoField decoration
obscureTextboolNoFor passwords
keyboardTypeTextInputTypeNoKeyboard type
validatorFormFieldValidatorNoValidation function

SimplrTextFormField

For use with Flutter's Form widget:

Form(
key: _formKey,
child: Column(
children: [
SimplrTextFormField(
tracker: simplr,
fieldName: 'email',
controller: _emailController,
decoration: InputDecoration(labelText: 'Email'),
validator: (v) => v!.isEmpty ? 'Required' : null,
),
SimplrTextFormField(
tracker: simplr,
fieldName: 'password',
controller: _passwordController,
obscureText: true,
decoration: InputDecoration(labelText: 'Password'),
validator: (v) => v!.length < 8 ? 'Min 8 chars' : null,
),
ElevatedButton(
onPressed: () {
if (_formKey.currentState!.validate()) {
_submit();
}
},
child: Text('Submit'),
),
],
),
)

Complete Example

class SignupScreen extends StatefulWidget {

_SignupScreenState createState() => _SignupScreenState();
}

class _SignupScreenState extends State<SignupScreen> {
final _simplr = SimplrFraud(
config: SimplrFraudConfig(collectBiometrics: true),
);
final _formKey = GlobalKey<FormState>();
final _emailController = TextEditingController();
final _passwordController = TextEditingController();


void initState() {
super.initState();
_simplr.initialize();
}

Future<void> _submit() async {
final signals = await _simplr.collect(context);

final response = await http.post(
Uri.parse('/api/signup'),
body: jsonEncode({
'email': _emailController.text,
'password': _passwordController.text,
'signals': signals.toJson(),
}),
);

// Handle response...
}


Widget build(BuildContext context) {
return Scaffold(
body: SimplrForm(
tracker: _simplr,
child: Form(
key: _formKey,
child: Padding(
padding: EdgeInsets.all(16),
child: Column(
children: [
SimplrTextFormField(
tracker: _simplr,
fieldName: 'email',
controller: _emailController,
decoration: InputDecoration(labelText: 'Email'),
keyboardType: TextInputType.emailAddress,
),
SizedBox(height: 16),
SimplrTextFormField(
tracker: _simplr,
fieldName: 'password',
controller: _passwordController,
decoration: InputDecoration(labelText: 'Password'),
obscureText: true,
),
SizedBox(height: 24),
ElevatedButton(
onPressed: () {
if (_formKey.currentState!.validate()) {
_submit();
}
},
child: Text('Sign Up'),
),
],
),
),
),
),
);
}


void dispose() {
_emailController.dispose();
_passwordController.dispose();
super.dispose();
}
}