Dart/Flutter: A simple delta-time performance debugging technique

As a brief note today, if you ever need to debug some Dart/Flutter code to see how much time that code is taking (such as to measure performance), here’s a manual approach you can use to determine the “delta time” between two Dart statements:

final t1 = DateTime.now();
// the source code you
// want to test
// is in here
final t2 = DateTime.now();
debugPrint('DELTA TIME: ${t2.difference(t1)}');

I just used this code to find a significant performance bottleneck, so while it’s not as sophisticated as other techniques, it was a nice performance-debugging tool today.