result

install

pubspec.yaml

dependencies:
  # DateTimeFormat
  intl: ^0.16.0

String to Date

final date =DateFormat('yyyy-MM-dd').parse('2000-01-01')

Date to String

final dateStr = DateFormat('yyyy-MM-dd').format(DateTime.now());


code

import 'package:intl/intl.dart';

Widget _buildTimeDetail() {
    var fromDate = DateFormat('yyyy-MM-dd\nHH:mm').format(DateTime.now());
    var toDate = DateFormat('yyyy-MM-dd\nHH:mm').format(DateTime.now());

    return Row(
      children: <Widget>[
        Padding(padding: EdgeInsets.all(20.0)),
        FlatButton(
            onPressed: () {},
            child: Text(
              fromDate,
              textAlign: TextAlign.center,
              style: TextStyle(color: Colors.black54, fontSize: 18.0),
            )),
        Icon(
          Icons.chevron_right,
          size: 35.0,
        ),
        FlatButton(
            onPressed: () {},
            child: Text(
              toDate,
              textAlign: TextAlign.center,
              style: TextStyle(color: Colors.black54, fontSize: 18.0),
            )),
      ],
    );
  }
profile
𝙸 𝚊𝚖 𝚊 𝚌𝚞𝚛𝚒𝚘𝚞𝚜 𝚍𝚎𝚟𝚎𝚕𝚘𝚙𝚎𝚛 𝚠𝚑𝚘 𝚎𝚗𝚓𝚘𝚢𝚜 𝚍𝚎𝚏𝚒𝚗𝚒𝚗𝚐 𝚊 𝚙𝚛𝚘𝚋𝚕𝚎𝚖. 🇰🇷👩🏻‍💻

0개의 댓글