update template for gen_keycodes (#49884)

diff --git a/dev/tools/gen_keycodes/data/keyboard_key.tmpl b/dev/tools/gen_keycodes/data/keyboard_key.tmpl
index 740ea90..c23a284 100644
--- a/dev/tools/gen_keycodes/data/keyboard_key.tmpl
+++ b/dev/tools/gen_keycodes/data/keyboard_key.tmpl
@@ -45,7 +45,7 @@
 /// look at the physical key to make sure that regardless of the character the
 /// key produces, you got the key that is in that location on the keyboard.
 ///
-/// {@tool snippet --template=stateful_widget_scaffold}
+/// {@tool sample --template=stateful_widget_scaffold}
 /// This example shows how to detect if the user has selected the logical "Q"
 /// key.
 ///
@@ -127,7 +127,7 @@
   ///
   /// [keyId] must not be null.
   ///
-  /// {@tool sample}
+  /// {@tool snippet}
   /// To save executable size, it is recommended that the [debugName] be null in
   /// release mode. You can do this by using the [kReleaseMode] constant.
   ///
@@ -167,12 +167,12 @@
   int get hashCode => keyId.hashCode;
 
   @override
-  bool operator ==(dynamic other) {
+  bool operator ==(Object other) {
     if (other.runtimeType != runtimeType) {
       return false;
     }
-    final LogicalKeyboardKey typedOther = other;
-    return keyId == typedOther.keyId;
+    return other is LogicalKeyboardKey
+        && other.keyId == keyId;
   }
 
   /// Returns the [LogicalKeyboardKey] constant that matches the given ID, or
@@ -246,7 +246,7 @@
   /// [control], so that the question "is any control key down?" can be asked.
   static Set<LogicalKeyboardKey> collapseSynonyms(Set<LogicalKeyboardKey> input) {
     final Set<LogicalKeyboardKey> result = <LogicalKeyboardKey>{};
-    for (LogicalKeyboardKey key in input) {
+    for (final LogicalKeyboardKey key in input) {
       final LogicalKeyboardKey synonym = _synonyms[key];
       result.add(synonym ?? key);
     }
@@ -331,7 +331,7 @@
 /// looking for "the key next next to the TAB key", since on a French keyboard,
 /// the key next to the TAB key has an "A" on it.
 ///
-/// {@tool snippet --template=stateful_widget_scaffold}
+/// {@tool sample --template=stateful_widget_scaffold}
 /// This example shows how to detect if the user has selected the physical key
 /// to the right of the CAPS LOCK key.
 ///
@@ -407,7 +407,7 @@
   ///
   /// The [usbHidUsage] must not be null.
   ///
-  /// {@tool sample}
+  /// {@tool snippet}
   /// To save executable size, it is recommended that the [debugName] be null in
   /// release mode. You can do this using the [kReleaseMode] constant.
   ///
@@ -440,12 +440,12 @@
   int get hashCode => usbHidUsage.hashCode;
 
   @override
-  bool operator ==(dynamic other) {
+  bool operator ==(Object other) {
     if (other.runtimeType != runtimeType) {
       return false;
     }
-    final PhysicalKeyboardKey typedOther = other;
-    return usbHidUsage == typedOther.usbHidUsage;
+    return other is PhysicalKeyboardKey
+        && other.usbHidUsage == usbHidUsage;
   }
 
   @override