alexeyinkin commented on code in PR #24865:
URL: https://github.com/apache/beam/pull/24865#discussion_r1063237039


##########
playground/frontend/playground_components/lib/src/widgets/snippet_editor.dart:
##########
@@ -16,120 +16,69 @@
  * limitations under the License.
  */
 
-import 'dart:math';
-
 import 'package:flutter/material.dart';
-import 'package:flutter/scheduler.dart';
-import 'package:flutter_code_editor/flutter_code_editor.dart';
 
+import '../constants/sizes.dart';
 import '../controllers/snippet_editing_controller.dart';
-import '../theme/theme.dart';
-
-class SnippetEditor extends StatefulWidget {
-  final SnippetEditingController controller;
-  final bool isEditable;
+import 'loading_indicator.dart';
+import 'snippet_file_editor.dart';
+import 'tabbed_snippet_editor.dart';
 
-  SnippetEditor({
+class SnippetEditor extends StatelessWidget {
+  const SnippetEditor({
     required this.controller,
     required this.isEditable,
-  }) : super(
-    // When the example is changed, will scroll to the context line again.
-    key: ValueKey(controller.selectedExample),
-  );
-
-  @override
-  State<SnippetEditor> createState() => _SnippetEditorState();
-}
-
-class _SnippetEditorState extends State<SnippetEditor> {
-  bool _didAutoFocus = false;
-  final _focusNode = FocusNode();
-  final _scrollController = ScrollController();
-
-  @override
-  void didChangeDependencies() {
-    super.didChangeDependencies();
-
-    if (!_didAutoFocus) {
-      _didAutoFocus = true;
-      SchedulerBinding.instance.addPostFrameCallback((_) {
-        if (mounted) {
-          _scrollSoCursorIsOnTop();
-        }
-      });
-    }
-  }
-
-  void _scrollSoCursorIsOnTop() {
-    _focusNode.requestFocus();
+    this.actionsWidget,
+  });
 
-    final position = max(widget.controller.codeController.selection.start, 0);
-    final characterOffset = _getLastCharacterOffset(
-      text: widget.controller.codeController.text.substring(0, position),
-      style: kLightTheme.extension<BeamThemeExtension>()!.codeRootStyle,
-    );
+  final SnippetEditingController controller;

Review Comment:
   Flutter itself uses just `controller` when the widget makes it clear: 
`TextField`, `ListView`, etc.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to