custom_text_field_new 0.0.1 copy "custom_text_field_new: ^0.0.1" to clipboard
custom_text_field_new: ^0.0.1 copied to clipboard

A reusable custom text field widget for Flutter apps.

example/lib/main.dart

import 'package:custom_text_field_new/custom_text_field_new.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

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

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

  @override
  Widget build(BuildContext context) {
    return ScreenUtilInit(
      designSize: const Size(375, 812),
      builder: (_, __) {
        return MaterialApp(
          title: 'Custom Text Field Demo',
          theme: ThemeData(primarySwatch: Colors.blue),
          home: const ExampleScreen(),
        );
      },
    );
  }
}

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

  @override
  State<ExampleScreen> createState() => _ExampleScreenState();
}

class _ExampleScreenState extends State<ExampleScreen> {
  final _formKey = GlobalKey<FormState>();
  final TextEditingController _controller = TextEditingController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text("Custom Text Field Example")),
      body: Padding(
        padding: const EdgeInsets.all(16),
        child: Form(
          key: _formKey,
          child: Column(
            children: [
              CustomTextFormField(
                hintText: "Enter your email",
                controller: _controller,
                keyboardType: TextInputType.emailAddress,
                onChanged: (value) => debugPrint("Changed: $value"),
                validator: (val) => val == null || val.isEmpty ? "Required" : null,
                inputFormatters: const [],
              ),
              const SizedBox(height: 20),
              ElevatedButton(
                onPressed: () {
                  if (_formKey.currentState!.validate()) {
                    debugPrint("Submitted: ${_controller.text}");
                  }
                },
                child: const Text("Submit"),
              )
            ],
          ),
        ),
      ),
    );
  }
}
0
likes
140
points
25
downloads

Publisher

unverified uploader

Weekly Downloads

A reusable custom text field widget for Flutter apps.

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_screenutil

More

Packages that depend on custom_text_field_new