If someone wants to convert a date in string format to some other string format first use DateTime.parse("2022-05-24") then pass it to DateFormat("date pattern").format() like
dateFormate = DateFormat("dd-MM-yyyy").format(DateTime.parse("2022-05-24"));
You can use intl.dart to formate any date . Here is a simple example of this:
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
class Home extends StatefulWidget {
Home({Key key}) : super(key: key);
_HomeState createState() => _HomeState();
}
class _HomeState extends State<Home> {
String dateFormate;
@override
Widget build(BuildContext context) {
dateFormate = DateFormat("dd-MM-yyyy").format(DateTime.parse("2022-05-24"));
return Container(
child: Text(dateFormate),
);}}