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

패키지 상세v1.2.2

dart_gsheet_remote_config

Dart/Flutter 앱의 동작, 설정 등을 업데이트 없이 변경하기 위해 Google 시트를 원격 구성으로 사용할 수 있는 패키지입니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
77
좋아요
7
Pub 점수
160

패키지 설치

flutter pub add dart_gsheet_remote_config

패키지 개요

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

dart_gsheet_remote_config는 Flutter 및 Dart 애플리케이션에서 실시간으로 Google 시트에서 설정 값을 가져올 수 있게 해주며, 새로운 릴리스 없이도 앱의 동작을 동적으로 업데이트할 수 있습니다. Google 시트를 원격 설정 소스로 간주함으로써 개발자는 기능, 플래그 또는 설정을 실시간으로 조정할 수 있습니다. 이 패키지는 Android, iOS, 웹, macOS, Windows, Linux 등 여러 플랫폼을 지원하여 유연하고 확장 가능한 앱 관리에 적합합니다.

사용 사례

  • 동적 기능 전환
  • 실시간 UI 테마 변경
  • 환경별 구성
  • A/B 테스트 구성
  • 원격 디버깅 및 모니터링
  • 배포 없이 즉시 앱 업데이트

주요 기능

  • Google Sheets를 구성 소스로 사용
  • 실시간 구성 업데이트
  • 다중 플랫폼 지원
  • Flutter/Dart와의 간단한 통합
  • Google Sheets API를 통한 보안 접근
  • 자동 캐시 처리

적합한 대상

  • 자주 구성 변경이 필요한 앱
  • 여러 환경을 관리하는 팀
  • A/B 테스트를 사용하는 프로젝트
  • 작은 수정을 위해 앱 스토어 제출을 피하는 개발자
  • 빠른 반복이 필요한 제품

고려 사항

  • Google Cloud 프로젝트 설정이 필요합니다
  • 적절한 인증(OAuth 2.0)이 필요합니다
  • 인터넷 연결에 의존합니다
  • 초기 로드에 대한 잠재적인 지연
  • Google Sheets API의 속도 제한
  • 민감한 데이터는 암호화되어야 합니다

원본 README

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

Dart Google Sheet Remote Config

pub package

This is a package that allows you to use Google Sheets as a remote config for changing your Dart/Flutter app's behaviors, settings,.. without updating. It is inspired by @theapache64's blog.

How it works

MUST READ before use

  • If you have some configs (API key, token,...) related to security, please DO NOT use this package, because it is PUBLIC and NOT SECURE.

Setup

Google Sheet
  • Create a Google Sheet document, make it PUBLIC & READ ONLY (If not you will get 401, in the future I will find the way to inject auth token for private sheeet) and put an easy to remember document name.

image

  • Add your data to sheet in format:
    • First column will be keys
    • Second column will be values

image_2

  • MUST READ: Every values in sheet is marked as String. For int, doube, bool, we should convert it to String, use TO_TEXT fomular to convert value to String type:

image_3

  • You can create more than 1 worksheet to manage your config better and it can be selected to get correct data.

image_4

Dart
dart pub add dart_gsheet_remote_config
Flutter
flutter pub add dart_gsheet_remote_config

How to use

Create your SheetRemoteConfig instance.

import 'package:dart_gsheet_remote_config/dart_gsheet_remote_config.dart';

final remoteConfig = SheetRemoteConfig();

SheetRemoteConfig has a param Client from http package so you can pass your custom Client object when create SheetRemoteConfig instance.

import 'package:dart_gsheet_remote_config/dart_gsheet_remote_config.dart';
import 'package:http/http.dart' as http;

final client = http.Client();

final remoteConfig = SheetRemoteConfig(client: client);
Fetch remote config data

SheetRemoteConfig provides initilize function and you must pass id and sheetName to initilize remote config:

  • Document id you can find it in your Google Sheet document Url. For example your Sheet url is https://docs.google.com/spreadsheets/d/123456789, id will be 123456789.

  • sheetName is worksheet name, nullable, first worksheet will be used if null or passed value is not found.

import 'package:dart_gsheet_remote_config/dart_gsheet_remote_config.dart';

final remoteConfig = SheetRemoteConfig();

await remoteConfig.initilize(id: '123456789'); // First worksheet will be used

await remoteConfig.initilize(id: '123456789', sheetName: 'Sheet1'); // Use specific worksheet name

MUST READ: id mustn't be hardcode if you don't want others to use your remote config. You can use id as .env field or via dart-define and pass it to your app via environment variable. You can use some packages like flutter_dotenv, envied to load .env file.

Get data from remote

SheetRemoteConfig fetchs data in CSV format, data is returned in key-value format, you can key to get value via get functions, currently SheetRemoteConfig supports String, int, double, bool.

Example response:

"key1","TRUE"
"key2","10"
"key3","value from key 3"
"key4,"1.0"

And get data:

final valueKey1 = remoteConfig.getBool('key1');
print(valueKey1); // true

final valueKey2 = remoteConfig.getInt('key2');
print(valueKey2); // 10

final valueKey3 = remoteConfig.getString('key3');
print(valueKey3); // value from key 3

final valueKey4 = remoteConfig.getDouble('key4');
print(valueKey4); // 1.0

If provided key is not found or provided T is incorrect, get functions will return null.

final valueKey5 = remoteConfig.getString('key5');
print(valueKey5); // null

You can pass defaultValue when get functions returns null.

final valueKey5 = remoteConfig.getString('key5', defaultValue: 'this is default value');
print(valueKey5); // this is default value

Get all data from remote

SheetRemoteConfig provides getAll function to get all data from remote.

final allData = remoteConfig.getAll();
print(allData); // {key1: true, key2: 10, key3: value from key 3, key4: 1.0}

Happy coding

That's all for now! Want a feature? Found a bug? Create an issue!

카테고리

의존성

의존성 목록 1 개

소스 저장소

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

아직 데이터가 없습니다.