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

패키지 상세v0.1.5+1

framy_annotation

framy_generator용 주석. framy_generator 없이는 이 패키지가 아무것도 하지 않습니다.

30일 다운로드
23
좋아요
28
Pub 점수
40

패키지 설치

flutter pub add framy_annotation

패키지 개요

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

Framy_annotation은 Flutter 애플리케이션의 코드 생성을 간소화하기 위해 framy_generator와 함께 사용되는 주석을 제공합니다. 개발자가 데이터 모델 및 기타 구조를 선언적으로 정의할 수 있게 해주며, 생성기가 이를 처리하여 JSON 직렬화, 동등성 검사, copyWith 메서드와 같은 뼈대 코드를 생성합니다. 이 패키지는 순수한 주석 공급원이며 별도로 기능하지 않으며, 컴파일 중에 framy_generator가 활성화되어 있어야 합니다. 수동 구현을 줄여 깔끔하고 타입 안전하며 효율적인 Dart 코드 유지 관리를 쉽게 만듭니다.

사용 사례

  • JSON 직렬화 코드 생성
  • 불변 데이터 클래스 만들기
  • copyWith 메서드 자동화
  • 값 동등성 구현
  • 모델 클래스 내 빈번한 코드 줄이기

주요 기능

  • 선언적 모델 정의
  • framy_generator와의 통합
  • 자동 코드 생성
  • 불변성 지원
  • 수동 보일러플레이트 감소

적합한 대상

  • 코드 생성을 사용하는 Flutter 프로젝트
  • 유지보수 가능한 데이터 모델을 우선시하는 팀
  • 반복적인 Dart 코드를 피하는 개발자
  • JSON 직렬화가 필요한 프로젝트
  • 값 객체를 많이 사용하는 앱

고려 사항

  • framy_generator 설치가 필요합니다
  • 런타임 기능 없음
  • 생성에 주석을 올바르게 사용해야 합니다
  • 비생성기 워크플로우와 호환되지 않습니다
  • 실행을 위해 build_runner에 의존

원본 README

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

Framy

Example apps Acceptance tests Unit tests License: LGPL v3

A convenient code generator for app styleguide, gallery, wireframes and/or storyboard.

👉 Official documentation 👈

Packages

In order to use Framy, you will need two following packages:

  • framy_annotation - A package containing annotation classes.
  • framy_generator - A powerful code generator which creates whole application based on the annotations used.
Package Pub
framy_annotation pub package
framy_generator pub package

Examples

ezgif com-video-to-gif (16)

Idea

The idea behind Framy is to allow developers, designers, testers, managers and clients to easily access the components used in the Flutter app.

Framy is annotation-driven tool based on which you can generate:

  • a style guide describing the theme of your app
  • a component gallery showing the widgets you have written in out-of-context way
  • a playground for testing widgets with a variety of dependencies
  • and much more coming soon...
What makes Framy special?
  • Fully responsive
    • The generated application is mobile, tablet, desktop and web friendly. Framy generates a separate main file with a separate MaterialApp but it does use the same widgets you are using in your own Flutter app.
  • Standalone
    • You can easily host generated app the way you prefer or just run it locally. (Automated hosting of Framy App is planned as well 😉)
  • Non-invasive
    • Framy doesn't require using any special widgets to be working. There is no Framy widget to wrap your app in so it doesn't affect your actual product. Only annotations.

Installation

Get packages

To use Framy, you will need your typical build_runner/code-generator setup.
First, install build_runner and Framy by adding them to your pubspec.yaml file:

dependencies:
  framy_annotation:

dev_dependencies:
  build_runner:
  framy_generator:
Add the @FramyApp annotation

@FramyApp annotation is coming from framy_annotations package. It's only purpose is to specify where the Framy app should be generated. Without this, the generator will not work. There should be only one @FramyApp annotation for the project.

@FramyApp() //<--- Add this annotation
class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(...);
  }
}
Run the generator

You can either run flutter pub run build_runner build to generate the app from the current code or flutter pub run build_runner watch to keep listening to changes in the source code and update the Framy app accordingly.

Run the generated app

Generator creates a new main file. Run flutter run lib/main.app.framy.dart to use Framy!

Annotations

Framy Annotations package offers a variety of annotations to generate the widest variety of pages in your Framy App.

FramyTheme

FramyTheme points out the ThemeData used in the Flutter application.

Using with ThemeData method or field

Since Framy uses the same widgets you do, it should use the same Theme as well. Use FramyTheme annotations to specify the Theme you are using. Based on that, Framy will generate your typography and color palette as well as it will use that theme for any other widget in the catalog.

@FramyTheme()
ThemeData getThemeData() => ThemeData(primarySwatch: Colors.orange);

Method annotated with FramyTheme must be public (available to use from outside the file)!

Using with custom theme class

Alternatively, you can use FramyTheme annotation with your own Theme class. If you have any colors (methods, fields, getters) defined in a class annotated with FramyTheme they will also be used in your color palette.

@FramyTheme()
 class AppTheme {
   static ThemeData get getTheme => ThemeData(primarySwatch: Colors.orange);
   Color get myAppBlack => Colors.black;
   static const myCompanyColorWhite = Color(0xFFFEFEFE);
}

There can be only one ThemeData accessor annotated in a project

FramyWidget

Annotate your Widget classes to include them in the gallery.

Framy will generate a dependencies panel which will allow the user to pass any parameters that are defined in the Widget's constructor.

@FramyWidget()
class CounterTitle extends StatelessWidget {
  final String verb;
  final int counter;

  const CounterTitle({this.verb = 'pushed', this.counter = 0});

  @override
  Widget build(BuildContext context) {
    return Column(
      key: Key('Counter title'),
      mainAxisAlignment: MainAxisAlignment.center,
      children: <Widget>[
        Text('You have $verb the button this many times:'),
        Text('$counter', style: Theme.of(context).textTheme.headline4),
      ],
    );
  }
}
FramyModel

Annotate your model classes to pass more complex parameters to your widgets

FramyWidget's constructor dependencies support by default only primitive types. In many cases you will pass a custom object instead of String or int. If you want to add an option to change custom dependencies, use FramyModel annotation with your model class.

@FramyModel()
class User {
  final String firstName;
  final String lastName;
  final int age;
  final List<String> emails;

  User(this.firstName, this.lastName, this.age, {this.emails});
}

You can annotate enums the same way:

@FramyModel()
enum Gender {female, male, other}

If your class uses other custom classes (e.g. Address in User), the subclasses have to be annotated with @framyModel as well

FramyPreset

Define dependency presets to speed up testing parameters to your widgets

In cases when your models have a lot of dependencies and it would be a big hustle to click them all through, you can define a preset object models which will be accessible in dependencies panel.

@FramyPreset()
User teenageJohn() => User('John', 'Smith', 13);

Since presets will be part of your normal source code, we recommend having them in a separate file, e.g. for User presets file user.framy.dart would do. :)

FramyUseProvider

If your widget dependency is passed by Provider and not constructor, just use @FramyUseProvider annotation

FramyUserProvider with FramyWidget will cause the generated app to pass a dependency using wrapped Provider around your widget.

@FramyUseProvider(User)
@framyWidget
class ProfilePage extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return Consumer<User>( //<-- Framy will take care of this
      builder: (context, user, child) {
        return ...;
      },
    );
  }
}

Maintenance

Our purpose is to make this tool as comprehensive as possible. We are trying to constantly improve it, add new features, handle new cases and fix any bugs.

If there is any use-case that we do not support and you think we should, feel free to submit an issue on GitHub. 🙂

카테고리

소스 저장소

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

아직 데이터가 없습니다.