Line data Source code
1 : // Copyright 2023 The terCAD team. All rights reserved. 2 : // Use of this source code is governed by a CC BY-NC-ND 4.0 license that can be found in the LICENSE file. 3 : 4 : import 'package:app_finance/_classes/controller/focus_controller.dart'; 5 : import 'package:app_finance/design/wrapper/focus_wrapper.dart'; 6 : import 'package:flutter/material.dart'; 7 : 8 : abstract class AbstractSelector extends StatefulWidget { 9 : final dynamic value; 10 : 11 1 : const AbstractSelector({super.key, this.value}); 12 : } 13 : 14 : abstract class AbstractSelectorState<T extends AbstractSelector> extends State<T> { 15 : late FocusNode focus; 16 : late FocusController focusController; 17 : final textController = SearchController(); 18 : 19 1 : @override 20 : void dispose() { 21 2 : textController.dispose(); 22 1 : super.dispose(); 23 : } 24 : 25 : void onTap(BuildContext context); 26 : 27 : Widget buildContent(BuildContext context); 28 : 29 1 : @override 30 : Widget build(BuildContext context) { 31 2 : focusController = FocusWrapper.of(context) ?? FocusController(); 32 5 : focus = focusController.bind(this, context: context, value: widget.value); 33 1 : return Focus( 34 3 : autofocus: mounted && focusController.isFocused(this) && widget.value == null, 35 1 : child: buildContent(context), 36 : ); 37 : } 38 : }