date_format_field 0.1.0 copy "date_format_field: ^0.1.0" to clipboard
date_format_field: ^0.1.0 copied to clipboard

An automatic date formater widget.

example/lib/main.dart

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

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

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

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

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

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  DateTime? _date;

  String display() {
    if (_date == null) {
      return 'NONE';
    } else {
      return 'year:${_date!.year}\nmonth:${_date!.month}\nday:${_date!.day}';
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Date Formater field'),
      ),
      body: SafeArea(
          child: SingleChildScrollView(
        child: Padding(
          padding: const EdgeInsets.symmetric(horizontal: 20),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              const SizedBox(height: 20),
              Text(display()),
              const SizedBox(height: 20),
              const Text('Date Formater field'),
              DateFormatField(
                type: DateFormatType.type4,
                addCalendar: true,
                decoration: const InputDecoration(
                  labelStyle: TextStyle(
                    fontWeight: FontWeight.bold,
                    fontSize: 18,
                    fontStyle: FontStyle.italic,
                  ),
                  // border: InputBorder.none,
                  label: Text("Date"),
                ),
                onComplete: (date) {
                  setState(() {
                    _date = date;
                  });
                },
              ),
            ],
          ),
        ),
      )),
    );
  }
}
14
likes
140
points
598
downloads

Publisher

unverified uploader

Weekly Downloads

An automatic date formater widget.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on date_format_field