I want to convert utc time string to local time data - Flutter [closed]

I have an app and in that app I have to show chart but when I get chart data from backhand it form in UTC but my client is from San Francisco so he receive has invalid data because of different timezone

So I want to create a function that can change time according to user local time zone

How can I create that?


you can use toLocal method. try below code

    var date = DateFormat("yyyy-MM-dd HH:mm:ss").parse(dateUtc, true);
    var local = date.toLocal().toString();
    print(local);