ms_formkit 1.0.0 copy "ms_formkit: ^1.0.0" to clipboard
ms_formkit: ^1.0.0 copied to clipboard

A customizable Flutter form field toolkit with advanced features like password strength, required field validation, prefix/suffix icons, and more.

example/main.dart

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

/// Example app demonstrating the usage of `CustomTextField`.
void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'ms_formkit Example',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const ExampleFormPage(),
    );
  }
}

class ExampleFormPage extends StatefulWidget {
  const ExampleFormPage({super.key});

  @override
  State<ExampleFormPage> createState() => _ExampleFormPageState();
}

class _ExampleFormPageState extends State<ExampleFormPage> {
  final _nameController = TextEditingController();
  final _phoneController = TextEditingController();
  final _emailController = TextEditingController();
  final _passwordController = TextEditingController();
  final _confirmPasswordController = TextEditingController();

  String submittedData = "";

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text("Registration Form")),
      body: SingleChildScrollView(
        padding: const EdgeInsets.all(16.0),
        child: Column(
          children: [
            CustomTextField(
              controller: _nameController,
              title: "First Name",
              isRequired: true,
              showBorder: true,
            ),
            const SizedBox(height: 16),

            CustomTextField(
              controller: _phoneController,
              title: "Phone Number",
              onlyNumbers: true,
              keyboardType: TextInputType.phone,
              isRequired: true,
              showBorder: true,
              maxLength: 10,
            ),
            const SizedBox(height: 16),

            CustomTextField(
              controller: _emailController,
              title: "Email Address",
              keyboardType: TextInputType.emailAddress,
              isRequired: true,
              showBorder: true,
            ),
            const SizedBox(height: 16),

            CustomTextField(
              controller: _passwordController,
              title: "Password",
              isPassword: true,
              showPasswordStrength: true,
              isRequired: true,
              showBorder: true,
            ),
            const SizedBox(height: 16),

            CustomTextField(
              controller: _confirmPasswordController,
              title: "Confirm Password",
              isPassword: true,
              isRequired: true,
              showBorder: true,
            ),
            const SizedBox(height: 24),

            ElevatedButton(
              onPressed: () {
                if (_passwordController.text !=
                    _confirmPasswordController.text) {
                  ScaffoldMessenger.of(context).showSnackBar(
                    const SnackBar(
                      content: Text("Passwords do not match!"),
                      backgroundColor: Colors.red,
                    ),
                  );
                  return;
                }

                setState(() {
                  submittedData =
                      "Name: ${_nameController.text}\n"
                      "Phone: ${_phoneController.text}\n"
                      "Email: ${_emailController.text}";
                });
              },
              child: const Text("Submit"),
            ),

            const SizedBox(height: 20),

            if (submittedData.isNotEmpty)
              Container(
                padding: const EdgeInsets.all(12),
                decoration: BoxDecoration(
                  color: Colors.grey.shade100,
                  borderRadius: BorderRadius.circular(8),
                ),
                child: Text(submittedData),
              )
          ],
        ),
      ),
    );
  }
}
6
likes
150
points
7
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A customizable Flutter form field toolkit with advanced features like password strength, required field validation, prefix/suffix icons, and more.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

cupertino_icons, flutter

More

Packages that depend on ms_formkit