flutter_autofill 0.4.0 copy "flutter_autofill: ^0.4.0" to clipboard
flutter_autofill: ^0.4.0 copied to clipboard

outdated

A Flutter plugin for Android auto_fill

flutter_autofill #

Provides Android Autofill support for Flutter text fields.

Supports all Android hint types.

Add dependency #

dependencies:
  flutter_autofill: ^0.4.0

Usage #

At its simplest form, you can just wrap your TextField with Autofill widget:

import 'package:flutter_autofill/flutter_autofill.dart';
          Autofill(
                onAutofilled: (val) {
                   // set value in controller & cursor position after auto-filled value
                  _emailController.value = TextEditingValue(text: val, selection: TextSelection.fromPosition(TextPosition(offset: val.length)));
                },
                autofillHints: [FlutterAutofill.AUTOFILL_HINT_EMAIL_ADDRESS],
                autofillType: FlutterAutofill.AUTOFILL_TYPE_TEXT,
                textController: _emailController,
                child: TextField(
                  controller: _emailController,
                  decoration: InputDecoration(hintText: "Please enter your email"),
                ),
              ),

For Autofill to function properly and be available on subsequent visits of screen, you must notify Autofill when data has been submitted or cancelled.

  bool commited = false;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Autofill Widget screen'),
      ),
      body: WillPopScope(
        onWillPop: () async {
          if (!commited) {
            await FlutterAutofill.cancel();
          }
          return true;
        },
        child: ...
  void _onSubmit() async {
    await FlutterAutofill.commit();
    commited = true;
    ...
  }
5
likes
0
pub points
57%
popularity

Publisher

unverified uploader

A Flutter plugin for Android auto_fill

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_autofill