When we call identical() on two widgets created using their const constructors, it return false. Whereas while calling the same for two non widget objects it returns true.
Why is that ?
void main() {
final a = const Center(
child: const Padding(padding: const EdgeInsets.all(8),)
);
final b = const Center(
child: const Padding(padding: const EdgeInsets.all(8),)
);
assert(identical(a, b)); // false
var a1 = const EdgeInsets.all(8);
var b1 = const EdgeInsets.all(8);
assert(identical(a1, b1)); // true
}
[ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: 'package:todo_improve/main.dart': Failed assertion: line 17 pos 8: 'identical(a, b)': is not true.