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

패키지 상세v4.1.2

index_generator

라이브러리에 필요한 모든 내보내기를 포함하여 인덱스/바렐/라이브러리 파일을 자동으로 생성합니다.

AndroidiOSmacOSWindowsLinux
30일 다운로드
2.6만
좋아요
33
Pub 점수
140

패키지 설치

flutter pub add index_generator

패키지 개요

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

index_generator은 Flutter/Dart 패키지로, 인덱스(barrel) 파일 생성을 자동화하여 관련된 모든 Dart 파일에 대한 내보내기를 생성함으로써 라이브러리 구조를 단순화합니다. 여러 모듈이나 패키지를 포함한 대규모 코드베이스를 관리할 때 수작업을 줄이고 오류를 최소화합니다. 이 도구는 명령줄을 통해 개발 워크플로우에 원활하게 통합되어 디렉터리 간 일관되고 최신의 내보내기 선언을 보장합니다. 깨끗하고 유지보수 가능한 코드 구조를 중시하는 개발자에게 이상적입니다.

사용 사례

  • 내보내기 파일 생성 자동화
  • 정돈된 라이브러리 구조 유지
  • 패키지 개발 간소화
  • 수동 내보내기 오류 감소
  • 모듈형 앱 아키텍처 지원

주요 기능

  • 자동 바렐 파일 생성
  • 명령줄 통합
  • 여러 플랫폼을 지원합니다
  • 일관된 내보내기를 보장합니다
  • 필수 구성 최소화

적합한 대상

  • 대규모 플러터 프로젝트
  • 라이브러리 저자
  • 모듈러 코드베이스를 사용하는 팀
  • 자동화를 찾는 개발자
  • 자주 파일 재구성되는 프로젝트

고려 사항

  • pubspec.yaml에서 설정이 필요합니다
  • 수동 편집과 충돌할 수 있습니다
  • 제어된 디렉터리 구조에서 가장 잘 사용됨
  • 간단한 앱에는 적합하지 않습니다
  • 올바른 폴더 구성에 따라 달라집니다

원본 README

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

Index Generator

Automatically generate index / barrel files with all the exports needed for your library.

Stable release

There will be no more breaking changes

Usage

  1. Activate: dart/flutter pub global activate index_generator

  2. Create index_generator.yaml file or add in your pubspec.yaml file:

index_generator:
  exclude:
    - "**.g.dart"
  # Define the paths of the folders in which to generate the index files
  libraries:
    - directory_path: lib
  1. You can generate index files with: <dart|flutter> pub global run index_generator

Advance Usage

See more examples

index_generator:
  # You can define the default name of the index file
  default_file_name: barrel
  # You can define general filters for all indexes
  exclude:
    - "**.g.dart"
    - "{_,**/_}*.dart"
  libraries:
    - directory_path: lib
      # You can define specific filters for this index
      include:
        # You can define specific export folders paths
        - "src/**"
      # You can define specific export dart packages in index file.
      exports:
        - package: package:args/args.dart
          show:
            - ArgResults
          hide:
            - ArgParser
    - directory_path: generator
      # You can define the name of the index file
      file_name: main
      # Disable/Enable the generated code disclaimer
      disclaimer: false
      # Include/Exclude the library keyword in generated file
      include_library: true
      # Comments added on the generated file, like copyright
      comments: |
        Copyright (c) 2020 BreX900
      # Documentation added on the generated file above the library name
      # Note: docs are only included when include_library is true
      docs: |
        Automatically generate index / barrel / library files
        with all the export needed for your library.
      # You can define the name of the library to use within the index
      name: index_generator
      # Use package-style exports for internal files (e.g., 'package:app/main.dart' instead of 'main.dart')
      use_package_exports: true
      # Custom output path for the generated index file (optional)
      # If not specified, the file will be created in the directory_path
      output_path: lib/generated
  • directory_path: Path in which to create the index file. All filters will get the relative path from this directory
  • output_path: Custom output path for the generated index file. If not specified, the file will be created in the directory_path
  • file_name: Prioritize ownership in folders, otherwise it will use the one defined in the generator with default_file_name key. If it is missing, if the folder is lib it will use the package name otherwise the folder name
  • name: The name of the library used in the index dart file by the library keyword
  • include_library: Include or exclude the library keyword in the generated file. Defaults to true
  • docs: Documentation comments added above the library declaration. Only included when include_library is true
  • include | exclude: You can define filters that exclude or include files to be included in the index. The filters are passed paths relative to the index file. You can use Glob expressions.
  • exports: You can define specific export dart packages in index file. You can use package to export a dart file package or dart core library.
  • use_package_exports: When enabled, generates package-style exports for internal files (e.g., 'package:app/main.dart' instead of 'main.dart'). This is useful for libraries that want to ensure consistent import paths. Defaults to false.

Command

--help command output:


-s, --settings=<Define a yaml file path.> If not present use the "index_generator.yaml" file if it exists otherwise use the "pubspec.yaml" file.
-v, --[no-]verbose Print verbose logs
-h, --help

Build runner

index_generator can be run via build_runner. To do so, add the following dependancies:

dev_dependencies:
  build_runner: ^2.10.0
  index_generator: ^4.1.0

and enable it in build.yaml file

targets:
  $default:
    builders:
      index_generator:
        enabled: true

To generate use <dart|flutter> pub run build_runner <build|watch>

Features and bugs

Please file feature requests and bugs at the issue tracker.

Extra

  • mek_assets: Automatically generate dart classes / flutter pubspec entries for your assets files.
  • mek_data_class: Generate hashCode, ==, toString, copyWith and change methods with low code.

카테고리

의존성

의존성 목록 11 개

소스 저장소

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