pubspec.yaml
dependencies:
# DateTimeFormat
intl: ^0.16.0
final date =DateFormat('yyyy-MM-dd').parse('2000-01-01')
final dateStr = DateFormat('yyyy-MM-dd').format(DateTime.now());
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),
)),
],
);
}