alexeyinkin commented on code in PR #22477: URL: https://github.com/apache/beam/pull/22477#discussion_r931486211
########## playground/frontend/lib/modules/editor/components/share_dropdown/share_dropdown_body.dart: ########## @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import 'package:flutter/material.dart'; +import 'package:playground/modules/editor/components/share_dropdown/share_tabs/share_tabs.dart'; +import 'package:playground/modules/editor/components/share_dropdown/share_tabs_headers.dart'; +import 'package:playground/modules/output/components/output_header/tab_header.dart'; + +const _kTabsCount = 2; + +class ShareDropdownBody extends StatefulWidget { + const ShareDropdownBody({super.key}); + + @override + State<ShareDropdownBody> createState() => _ShareDropdownBodyState(); +} + +class _ShareDropdownBodyState extends State<ShareDropdownBody> + with SingleTickerProviderStateMixin { + late final tabController = TabController(vsync: this, length: _kTabsCount); + + @override + void dispose() { + tabController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TabHeader( + tabController: tabController, + tabsWidget: ShareTabsHeaders(tabController: tabController), + ), + Expanded( + child: ShareTabs(tabController: tabController), Review Comment: The use of ordinary `TabController` makes this fragile. In this file we hardcode the number of tabs as 2. Tab headers and tab contents are spread into 3 different widgets: `ShareTabHeaders`, `SnippetShareTabs`, `ExampleShareTabs`. These 4 locations should agree on the number of tabs and their order. Not that we have plans to change the tabs, but it is still hard to maintain. To solve such problems, I made this package some time ago: https://pub.dev/packages/keyed_collection_widgets I had been using it with all tab solutions for months, but it needs approval here. Can we use it? -- 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]
