custom_form_field 0.0.6 copy "custom_form_field: ^0.0.6" to clipboard
custom_form_field: ^0.0.6 copied to clipboard

A customizable and elegant form field

example/example.dart

import 'package:custom_form_field/custom_form_field.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  GlobalKey<FormState> key = GlobalKey<FormState>();
  String? _name;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("Custom form field Demo"),
      ),
      body: Form(
        key: key,
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            CustomFormField().field(
              question: "Name",
              canBeNull: false,
              formKey: key,
              onSavedCallback: (String val) {
                _name = val;
              },
              horizontalTextPadding: 20,
              verticalTextPadding: 10,
              labelTextStyle: const TextStyle(color: Colors.black),
              icon: const Icon(
                Icons.email_outlined,
                color: Colors.grey,
                size: 25,
              ),
              fieldTextFontSize: 15,
            ),
            Padding(
              padding: const EdgeInsets.only(top: 50),
              child: ElevatedButton(
                  onPressed: () {
                    key.currentState!.save();
                    debugPrint(_name);
                  },
                  child: const Text("SUBMIT")),
            )
          ],
        ),
      ),
    );
  }
}
7
likes
115
pub points
40%
popularity

Publisher

unverified uploader

A customizable and elegant form field

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (LICENSE)

Dependencies

flutter

More

Packages that depend on custom_form_field