확장 메서드를 제공하여 조상 컨텍스트 속성에 접근하는 것을 단순화하는 플러터 패키지입니다. 반복 코드를 줄입니다. 개발자는 `BuildContext.findAncestorWidgetOfExactType` 를 수동으로 호출하지 않고도 테마, 로컬라이제이션 또는 기타 상속 위젯을 컨텍스트에서 직접 가져올 수 있습니다. 이는 복잡한 위젯 트리에서 코드 가독성과 개발 속도를 향상시킵니다. 패키지는 가볍고 모든 주요 플러터 플랫폼과 호환됩니다.
사용 사례
테마 접근 간소화
컨텍스트 검색 보일러플레이트 줄이기
현지화 검색 간소화
위젯 트리 탐색 개선
코드 유지보수성 향상
UI 개발 가속화
주요 기능
컨텍스트용 확장 메서드
직접 조상 속성 접근
최소 성능 오버헤드
크로스 플랫폼 지원
더 깔끔하고 가독성 높은 코드
추가 종속성 없음
적합한 대상
더 깔끔한 컨텍스트 사용을 원하는 개발자
코드 가독성을 우선시하는 팀
깊은 위젯 계층 구조를 가진 프로젝트
Flutter 초보자가 컨텍스트 패턴 배우기
자주 테마 또는 로케일에 액세스하는 앱
고려 사항
조상 컨텍스트에만 제한
전체 컨텍스트 관리를 대체하지 않습니다
사용자 정의 컨텍스트 확장과 충돌할 수 있습니다
적절한 상태 관리와 함께 사용할 때 가장 효과적입니다
비조상 속성에 대한 액세스에는 적합하지 않습니다
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
Awesome Flutter Extensions
Awesome flutter extensions to remove boilerplate
Installation
Install using the Terminal:
flutter pub add awesome_flutter_extensions
Install adding the dependency in the pubspec.yaml:
dependencies:awesome_flutter_extensions:^1.0.0# Use the latest version from pub.dev
Install using Pubspec Assist (VSCode extensions):
Open the command palette:
(⇧ ⌘ P) on Mac
(Ctrl ⇧ P) on Windows
Then type Pubspec assist.. until you'll get Pubspec Assist: Add/Update dependencies.
Here type the name of the package: awesome_flutter_extensions and press ENTER ↵.
Why this split?
After creating extensions upon extensions, I admit that with context you could access an infinite number of things.
That's why I decided to split them up.
Sizes
To get the width of the screen, use:
// beforeMediaQuery.sizeOf(context).width
// after
context.sizes.width;