moform 0.1.2 copy "moform: ^0.1.2" to clipboard
moform: ^0.1.2 copied to clipboard

Reactive, model-driven, and type-safe forms for Flutter. A light wrapper around Flutter's TextFormField.

Moform #

Reactive, model-driven, and type-safe forms for Flutter.

Getting Started #

➤ Installation #

Add the following to your pubspec.yaml:

dependencies:
  moform: <version>

➤ Usage #

Using a StatefulWidget:

class EmailField extends StatefulWidget {
  @override
  State<EmailField> createState() => _EmailFieldState();
}

class _EmailFieldState extends State<EmailField> {
  String _email = '';

  @override
  Widget build(BuildContext context) {
    return StringField(
      value: _email,
      onChanged: (value) {
        setState(() => _email = value);
      },
    );
  }
}

Using Riverpod:

final emailProvider = StateProvider<String>((ref) => '');

class EmailField extends ConsumerWidget {
  @override
  Widget build(BuildContext context, WidgetRef ref) {
    final email = ref.watch(emailProvider);

    return StringField(
      value: email,
      onChanged: (value) {
        ref.read(emailProvider.notifier).state = value;
      },
    );
  }
}

Features #

➤ Typed Fields #

String

StringField(
  value: email,
  onChanged: (value) {
    setState(() => email = value);
  },
);

Int

IntField(
  value: age,
  onChanged: (value) {
    setState(() => age = value);
  },
);

➤ Custom Styles #

Use builder to provide a custom field widget.

StringField(
  value: email,
  onChanged: (value) {
    setState(() {
      email = value;
    });
  },
  builder: (context, controller) {
    return TextField(
      controller: controller,
      decoration: const InputDecoration(
        labelText: 'Custom Field',
      ),
    );
  },
);
5
likes
0
points
1.16k
downloads

Publisher

verified publishertienisto.com

Weekly Downloads

Reactive, model-driven, and type-safe forms for Flutter. A light wrapper around Flutter's TextFormField.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, meta

More

Packages that depend on moform