패키지, 저장소 및 앱 카테고리 검색

패키지 상세v1.2.0

focusable_control_builder

마우스 및 키보드에 올바르게 반응하는 사용자 지정 컨트롤을 쉽게 만들 수 있습니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
1.7천
좋아요
52
Pub 점수
140

패키지 설치

flutter pub add focusable_control_builder

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

키보드 및 마우스 포커스 처리를 올바르게 수행하면서 사용자 정의 UI 컨트롤을 쉽게 만들 수 있도록 도와주는 플러터 패키지입니다. 다양한 플랫폼 간에 일관되게 포커스 상태, 접근성 및 입력 이벤트를 관리하기 위해 빌더 패턴을 제공합니다. 개발자는 탭 탐색, 키보드 단축키, 포인터 상호작용에 적절하게 반응하는 버튼, 슬라이더 또는 폼 필드와 같은 인터랙티브 요소를 쉽게 구현할 수 있습니다. 이 패키지는 보조 기술과 터치 외의 입력 방식에 의존하는 사용자에게 원활한 사용자 경험을 보장합니다.

사용 사례

  • 접근성 있는 폼 입력 만들기
  • 사용자 정의 상호작용 위젯 만들기
  • 복잡한 UI에서 키보드 탐색 활성화
  • 스크린 리더 및 보조 기술 지원
  • 앱에서 탭 기반 탐색 구현
  • 데스크톱 및 웹용 반응형 컨트롤 설계

주요 기능

  • 내장된 포커스 상태 관리
  • 키보드 이벤트 처리
  • 마우스 포인터 통합
  • 크로스 플랫폼 일관성
  • 접근성 대응 디자인
  • 간단한 빌더 API

적합한 대상

  • 접근성 있는 앱을 개발하는 개발자
  • 데스크톱 및 웹 중심의 Flutter 프로젝트
  • 키보드 사용자 경험을 우선시하는 팀
  • 사용자 정의 위젯 생성기
  • 전체 키보드 탐색이 필요한 앱

고려 사항

  • 포커스 의미론에 대한 이해 필요
  • 시각적 피드백을 위해 추가적인 스타일링이 필요할 수 있습니다
  • 의미 있는 UI 패턴과 함께 사용하는 것이 가장 좋습니다
  • 간단한 터치 전용 인터페이스에는 필요하지 않습니다
  • 기존 포커스 트리와의 통합은 신중을 기울여야 할 수 있습니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

focusable_control_builder

Using FocusableControlBuilder you can quickly create a new control that will work properly on all platforms and input devices.

Working "properly" entails support for:

  • tab key traversal
  • focus / rollover states
  • modified mouse cursor
  • support for keyboard shortcuts (Enter/Space by default)

Under the hood, this builder wraps the built in FocusableActionDetector and you can read there for more details about how it all works.

For more information on why you'd use these widgets, see this blog post: https://blog.gskinner.com/archives/2021/06/flutter-building-custom-components-with-focusableactiondetector.html

🔨 Installation

$ flutter pub add focusable_control_builder
⚙ Import
import 'package:focusable_control_builder/focusable_control_builder.dart';

🕹️ Usage

To create a custom button just implement the FocusableControlBuilder.builder method and assign an onPressed handler:

class MyCustomButton extends StatelessWidget {
  const MyCustomButton(this.label, {Key? key, required this.onPressed}) : super(key: key);
  final String label;
  final VoidCallback onPressed;
  @override
  Widget build(BuildContext context) {
    return FocusableControlBuilder(
        onPressed: onPressed,
        builder: (_, FocusableControlState control) {
          // Decide which colors to use, based on .isFocused and .isHovered
          Color outlineColor = control.isFocused ? Colors.black : Colors.transparent;
          Color bgColor = control.isHovered ? Colors.blue.shade100 : Colors.grey.shade200;
          // Return custom button contents
          return Container(
            padding: const EdgeInsets.all(8),
            child: Text(label),
            decoration: BoxDecoration(
              color: bgColor,
              border: Border.all(color: outlineColor, width: 1),
            ),
          );
        });
  }
}
Custom Mouse Cursor

FocusableControlBuilder will assume you want a "hand" cursor for your control, which is typically the case. If you'd like a different cursor, just assign it:

return FocusableControlBuilder(
    cursor: SystemMouseCursors.resizeDown,
    ...
);
Request Focus On Press

FocusableControlBuilder will assume you want your control to request focus when it is pressed. To disable, just set this to false:

return FocusableControlBuilder(
    requestFocusOnPress: false,
    ...
);
Custom Shortcuts

FocusableControlBuilder will create a default activation action which handles [Submit] and [Enter] keys. To create custom keyboard shortcuts you can set the .shortcuts and .actions parameters. This is a bit beyond the scope of this doc, but if you'd like to learn how, checkout the FocusableActionDetector docs which contain an example.

🐞 Bugs/Requests

If you encounter any problems please open an issue. If you feel the library is missing a feature, please raise a ticket on Github and we'll look into it. Pull request are welcome.

📃 License

MIT License

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.