Flutter.Dart/Flutter 패키지 추천

[Flutter 추천 패키지] Flutter OSS Licenses

Auzii 2025. 1. 19. 21:38
300x250

앱을 배포할 때, 사용한 오픈소스 패키지의 라이선스를 포함하는 건 필수이다.
이를 oss launcher 로 쉽고 빠르게 한 방에 처리해보자.

 

 

1. flutter_oss_licenses 설치하기

pubspec.yaml 파일에 아래 내용을 추가해서 패키지를 가져와야 함. flutter_oss_licenses는 개발 환경에서만 사용되니까 dev_dependencies에 추가하는 게 중요.

yaml

dev_dependencies: 
	flutter_test: 
    	sdk: flutter 
    # Open Source License 관리용 패키지 
    flutter_oss_licenses: ^3.0.1
 

2. 라이선스 파일 생성하기

터미널에서 다음 명령어를 실행.

bash

flutter pub run flutter_oss_licenses:generate.dart

 

실행 후, 프로젝트 루트 경로에 oss_licenses.dart 파일이 생성.


3. 생성된 파일 이동 및 정리

  1. 생성된 oss_licenses.dart 파일을 lib/data 디렉터리(혹은 원하는 위치)로 이동.
  2. 필요 없는 부분이나 불필요한 정보는 직접 확인하고 정리해주면 돼.

4. 커스텀 폰트(Font) 추가하기

라이선스 정보에 앱에서 사용하는 커스텀 폰트도 추가해야 함. 보통 사용한 폰트의 OFL.txt나 라이선스 파일 내용을 그대로 복사해서 라이선스 목록에 넣으면 됌!

 

예를 들어, 다음처럼 LICENSE 텍스트에 포함시킬 수 있음:

Font: Roboto 
License: Open Font License (OFL) 
Details: https://fonts.google.com/specimen/Roboto

 


예시 코드

라이선스 목록을 앱에서 보여주는 간단한 예시 코드

- 라이센스 목록 페이지

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:matchmaker/data/oss_licenses.dart';
import 'package:matchmaker/view/9_settings/9_4_license/view_oss_licenses_misc.dart';

class MMLicencesPage extends StatelessWidget {
  const MMLicencesPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        // backgroundColor: Colors.transparent,
        title: const Text(
          "Licences",
          style: TextStyle(fontWeight: FontWeight.bold),
        ),
      ),
      body: ListView.builder(
        physics: const BouncingScrollPhysics(),
        itemCount: ossLicenses.length,
        itemBuilder: (_, index) {
          return Padding(
            padding: const EdgeInsets.all(4.0),
            child: Container(
              decoration: BoxDecoration(
                color: Theme.of(context).colorScheme.primary.withAlpha(100),
                borderRadius: BorderRadius.circular(8),
              ),
              child: ListTile(
                onTap: () {
                  Navigator.push(
                    context,
                    CupertinoPageRoute(
                      builder: (_) => LicenceDetailPage(
                        title: ossLicenses[index].name[0].toUpperCase() +
                            ossLicenses[index].name.substring(1),
                        licence: ossLicenses[index].license!,
                      ),
                    ),
                  );
                },
                //capitalize the first letter of the string
                title: Text(
                  ossLicenses[index].name[0].toUpperCase() +
                      ossLicenses[index].name.substring(1),
                ),
                subtitle: Text(
                  ossLicenses[index].description,
                  maxLines: 1,
                ),
              ),
            ),
          );
        },
      ),
    );
  }
}

 

- 라이센스 상세 페이지

import 'package:flutter/material.dart';

//detail page for the licence
class LicenceDetailPage extends StatelessWidget {
  final String title, licence;
  const LicenceDetailPage(
      {super.key, required this.title, required this.licence});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Colors.transparent,
        title: Text(title),
      ),
      body: Padding(
        padding: const EdgeInsets.all(8.0),
        child: Container(
          padding: const EdgeInsets.all(5),
          decoration: BoxDecoration(
              color: Theme.of(context).colorScheme.primary.withAlpha(100),
              borderRadius: BorderRadius.circular(8)),
          child: SingleChildScrollView(
            physics: const BouncingScrollPhysics(),
            child: Column(
              children: [
                Text(
                  licence,
                  style: const TextStyle(fontSize: 15),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}

 

- 예시 화면

 


이 방법으로 앱에 포함된 오픈소스 패키지들의 라이선스를 쉽게 정리할 수 있고, 배포 전에 항상 추가된 라이선스 정보를 한 번 더 확인해야 이후에 문제가 되지 않을 것 입니다.

관련해 궁금하거나 고쳐야할 부분, 추가 꿀팁은 댓글로 부탁드립니다~

 

 


Reference

1. https://pub.dev/packages/flutter_oss_licenses

 

flutter_oss_licenses | Dart package

A tool to generate detail and better OSS license list using pubspec.yaml/lock files.

pub.dev

2. https://medium.com/@anslemAnsy/generating-licenses-for-your-flutter-app-the-easy-way-99deec74aeb9

 

Generating licenses for your flutter app the easy way.

Generating licenses for your Flutter app can be a tedious and time-consuming task. This is especially true if you use several third-party…

medium.com

 

300x250

'Flutter.Dart > Flutter 패키지 추천' 카테고리의 다른 글

[Flutter 추천 패키지] url launcher  (0) 2025.01.12