[ermine] Fix crash in release build

For some reason, adding a listener to FocusNode object crashes deep
in flutter framework. This was happening in RawKeyboardListener
widget. This change removes that widget in ask_suggestion_list,
instead directly uses the RawKeyboard instance in ask_model.

Also fix build warning of missing 'uses-material-design' in ermine.

Bug: 57816

Test: Updated tests pass.
Change-Id: Ifdd75bce151e20f5db81130e4e12a644de604679
Reviewed-on: https://fuchsia-review.googlesource.com/c/experiences/+/414414
Reviewed-by: Chase Latta <chaselatta@google.com>
Testability-Review: Chase Latta <chaselatta@google.com>
Commit-Queue: Sanjay Chouksey <sanjayc@google.com>
diff --git a/session_shells/ermine/shell/lib/src/models/ask_model.dart b/session_shells/ermine/shell/lib/src/models/ask_model.dart
index fef05d3..e867638 100644
--- a/session_shells/ermine/shell/lib/src/models/ask_model.dart
+++ b/session_shells/ermine/shell/lib/src/models/ask_model.dart
@@ -6,7 +6,7 @@
 
 import 'package:flutter/material.dart';
 import 'package:flutter/services.dart'
-    show RawKeyDownEvent, RawKeyEventDataFuchsia;
+    show RawKeyboard, RawKeyDownEvent, RawKeyEventDataFuchsia;
 
 import '../utils/styles.dart';
 import '../utils/suggestion.dart';
@@ -65,12 +65,15 @@
   AskModel({
     @required SuggestionService suggestionService,
     this.onDismiss,
-  }) : _suggestionService = suggestionService;
+  }) : _suggestionService = suggestionService {
+    RawKeyboard.instance.addListener(handleKey);
+  }
 
   @override
   void dispose() {
     super.dispose();
     controller.dispose();
+    RawKeyboard.instance.removeListener(handleKey);
   }
 
   /// Called by [TextField]'s [onChanged] callback when text changes.
diff --git a/session_shells/ermine/shell/lib/src/widgets/ask/ask_suggestion_list.dart b/session_shells/ermine/shell/lib/src/widgets/ask/ask_suggestion_list.dart
index 19ac3c9..9362b5b 100644
--- a/session_shells/ermine/shell/lib/src/widgets/ask/ask_suggestion_list.dart
+++ b/session_shells/ermine/shell/lib/src/widgets/ask/ask_suggestion_list.dart
@@ -40,35 +40,30 @@
         }
       }
     });
-    return RawKeyboardListener(
-      onKey: model.handleKey,
-      focusNode: model.focusNode,
-      child: AnimatedBuilder(
-          animation: model.suggestions,
-          builder: (context, child) {
-            return Container(
-              decoration: model.suggestions.value.isNotEmpty && !unbounded
-                  ? BoxDecoration(
-                      color: ErmineStyle.kOverlayBackgroundColor,
-                      border: Border.all(
-                        color: ErmineStyle.kOverlayBorderColor,
-                        width: ErmineStyle.kOverlayBorderWidth,
-                      ),
-                      borderRadius: BorderRadius.all(Radius.zero),
-                    )
-                  : null,
-              constraints: unbounded
-                  ? null
-                  : BoxConstraints(maxHeight: _kListViewHeight),
-              child: AnimatedList(
-                controller: controller,
-                key: model.suggestionsListKey,
-                shrinkWrap: true,
-                itemBuilder: _buildItem,
-              ),
-            );
-          }),
-    );
+    return AnimatedBuilder(
+        animation: model.suggestions,
+        builder: (context, child) {
+          return Container(
+            decoration: model.suggestions.value.isNotEmpty && !unbounded
+                ? BoxDecoration(
+                    color: ErmineStyle.kOverlayBackgroundColor,
+                    border: Border.all(
+                      color: ErmineStyle.kOverlayBorderColor,
+                      width: ErmineStyle.kOverlayBorderWidth,
+                    ),
+                    borderRadius: BorderRadius.all(Radius.zero),
+                  )
+                : null,
+            constraints:
+                unbounded ? null : BoxConstraints(maxHeight: _kListViewHeight),
+            child: AnimatedList(
+              controller: controller,
+              key: model.suggestionsListKey,
+              shrinkWrap: true,
+              itemBuilder: _buildItem,
+            ),
+          );
+        });
   }
 
   Widget _buildItem(
diff --git a/session_shells/ermine/shell/pubspec.yaml b/session_shells/ermine/shell/pubspec.yaml
index 704ef34..ed37391 100644
--- a/session_shells/ermine/shell/pubspec.yaml
+++ b/session_shells/ermine/shell/pubspec.yaml
@@ -5,4 +5,4 @@
 description: A development shell for Fuchsia.
 
 flutter:
-
+  uses-material-design: true
diff --git a/session_shells/ermine/shell/test/ask_model_test.dart b/session_shells/ermine/shell/test/ask_model_test.dart
index 861000d..966fdf9 100644
--- a/session_shells/ermine/shell/test/ask_model_test.dart
+++ b/session_shells/ermine/shell/test/ask_model_test.dart
@@ -7,7 +7,7 @@
 import 'package:flutter/material.dart';
 import 'package:flutter/services.dart'
     show RawKeyDownEvent, RawKeyEventDataFuchsia;
-import 'package:test/test.dart';
+import 'package:flutter_test/flutter_test.dart';
 import 'package:mockito/mockito.dart';
 
 // ignore_for_file: implementation_imports
@@ -16,6 +16,8 @@
 import 'package:ermine/src/utils/suggestions.dart';
 
 void main() {
+  TestWidgetsFlutterBinding.ensureInitialized();
+
   ValueNotifier<bool> visibility;
   MockSuggestionService suggestionService;
   AskModel model;