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

패키지 상세v1.0.0

nested

수동으로 중첩하지 않고 여러 위젯을 중첩하는 데 도움이 되는 Flutter 위젯입니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
526만
좋아요
350
Pub 점수
150

패키지 설치

flutter pub add nested

패키지 개요

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

중첩 패키지는 여러 위젯을 중첩하는 것을 단순화하는 플러터 유틸리티입니다. 수동으로 중첩된 위젯 구조를 작성하지 않고도 깔끔하고 선언적인 방식으로 위젯들을 조합할 수 있게 해줍니다. 복잡한 UI 레이아웃에서 가독성과 유지보수성을 향상시켜 개발자가 위젯을 더 직관적인 방식으로 연결할 수 있도록 합니다. UI 코드의 반복 코드를 줄이는 데 이상적이며, 안드로이드, iOS, 웹, 맥OS, 윈도우, 리눅스를 포함한 모든 주요 플러터 플랫폼을 지원합니다.

사용 사례

  • 복잡한 위젯 계층 구조 간소화
  • 중첩 위젯 봇러플레이트 줄이기
  • UI 코드 가독성 향상
  • 레이아웃 조합 간소화
  • 재사용 가능한 위젯 체인 만들기
  • 대규모 UI의 유지보수성 향상

주요 기능

  • 선언적 위젯 중첩
  • 최소한의 보일러플레이트
  • 체인 가능한 위젯 조합
  • 크로스 플랫폼 지원
  • 깔끔하고 읽기 쉬운 구문
  • 추가 종속성 없음

적합한 대상

  • 더 깔끔한 UI 코드를 원하는 개발자
  • 깊이 중첩된 위젯을 가진 프로젝트
  • 코드 유지보수를 우선시하는 팀
  • UI 중심 애플리케이션
  • Flutter 초보자가 컴포지션을 배우고 있습니다
  • 경험 많은 개발자가 레이아웃 패턴 최적화

고려 사항

  • 위젯 조합에만 제한됨
  • 고급 레이아웃 위젯의 대체물이 아님
  • 신규 사용자에게 학습 곡선이 증가할 수 있음
  • 다른 레이아웃 전략과 함께 사용할 때 가장 효과적입니다
  • 상태 관리를 대체하지 않음
  • Flutter 위젯 트리에 대한 이해가 필요합니다

원본 README

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

pub package ci

A widget that simplifies the syntax for deeply nested widget trees.

Motivation

Widgets tend to get pretty nested rapidly. It's not rare to see:

MyWidget(
  child: AnotherWidget(
    child: Again(
      child: AndAgain(
        child: Leaf(),
      )
    )
  )
)

That's not very ideal.

There's where nested propose a solution. Using nested, it is possible to flatten the previous tree into:

Nested(
  children: [
    MyWidget(),
    AnotherWidget(),
    Again(),
    AndAgain(),
  ],
  child: Leaf(),
),

That's a lot more readable!

Usage

Nested relies on a new kind of widget: SingleChildWidget, which has two concrete implementation:

These are SingleChildWidget variants of the original Stateless/StatefulWidget.

The difference between a widget and its single-child variant is that they have a custom build method that takes an extra parameter.

As such, a StatelessWidget would be:

class MyWidget extends StatelessWidget {
  MyWidget({Key key, this.child}): super(key: key);

  final Widget child;

  @override
  Widget build(BuildContext context) {
    return SomethingWidget(child: child);
  }
}

Whereas a SingleChildStatelessWidget would be:

class MyWidget extends SingleChildStatelessWidget {
  MyWidget({Key key, Widget child}): super(key: key, child: child);

  @override
  Widget buildWithChild(BuildContext context, Widget child) {
    return SomethingWidget(child: child);
  }
}

This allows our new MyWidget to be used both with:

MyWidget(
  child: AnotherWidget(),
)

and to be placed inside children of [Nested] like so:

Nested(
  children: [
    MyWidget(),
    ...
  ],
  child: AnotherWidget(),
)

카테고리

소스 저장소

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