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 some code is taking, here’s a manual approach that you can use to determine the “delta time” between two 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 bottleneck, so while it’s not as sophisticated as other techniques, it was a nice performance-debugging tool today.