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

Provides Android Autofill support for Flutter text fields. Supports all Android hint types.

flutter_autofill #

Provides Android Autofill support for Flutter text fields.

Supports all Android hint types.

Add dependency #

dependencies:
  flutter_autofill: ^0.4.1

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
40
points
23
downloads

Publisher

unverified uploader

Weekly Downloads

Provides Android Autofill support for Flutter text fields. Supports all Android hint types.

Repository (GitHub)

License

BSD-2-Clause (license)

Dependencies

flutter

More

Packages that depend on flutter_autofill