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

패키지 상세v3.3.0

system_theme

시스템의 강조 색상을 검색하고 듣기 위한 플러터 플러그인입니다. 안드로이드, iOS, 웹, 윈도우, 맥OS 및 리눅스를 지원합니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
8.3천
좋아요
123
Pub 점수
160

패키지 설치

flutter pub add system_theme

패키지 개요

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

system_theme 패키지는 Android, iOS, Web, macOS, Windows, Linux를 포함한 여러 플랫폼에서 시스템의 강조 색상에 액세스하고 반응할 수 있도록 해줍니다. 현재 시스템 강조 색상을 가져오고 변경 사항을 감지하는 간단한 방법을 제공하여 디바이스 레벨 테마와 앱 UI의 일관성을 높입니다. 수동 테마 관리 없이 네이티브 시스템 미학을 따르려는 앱에 이상적입니다.

사용 사례

  • 앱 UI에서 시스템 강조 색상 일치
  • 시스템 설정을 기반으로 동적 테마 만들기
  • 네이티브한 외관과 느낌으로 크로스 플랫폼 앱 만들기
  • 시스템 테마가 변경될 때 색상이 자동으로 업데이트됩니다
  • 시스템 정의 색상 테마를 통한 접근성 향상

주요 기능

  • 시스템 강조 색상 변경 실시간 듣기
  • 모든 주요 운영 체제에 대한 크로스 플랫폼 지원
  • 현재 강조 색상을 검색하는 간단한 API
  • 시스템 테마가 변경될 때 자동 업데이트
  • 경량이고 통합하기 쉬움

적합한 대상

  • 네이티브에 가까운 UI를 목표로 하는 개발자
  • 동적 테마 적응이 필요한 앱
  • 접근성과 사용자 경험에 중점을 둔 프로젝트
  • 크로스 플랫폼 플러터 애플리케이션
  • 원활한 시스템 통합을 원하는 디자이너

고려 사항

  • 강조 색상에 제한됨; 전체 테마 모드를 관리하지 않음
  • 플랫폼 간에 동작이 약간 다를 수 있습니다
  • 일부 OS에서는 플랫폼별 권한이 필요합니다
  • 강조 색상 이상의 복잡한 테마 관리에는 적합하지 않습니다
  • 시스템 수준의 색상 사용 가능 여부에 따라 다릅니다

원본 README

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

system_theme

A flutter plugin to retrieve the current system theme information

Supported platforms
Platform Accent Color Listen to Color Changes Minimum Version
Android ✔️ Android 10+
iOS ✔️ iOS 14+
Windows ✔️ ✔️ Windows 10+
macOS ✔️ ✔️ Mojave 10.14+
Linux ✔️ GTK 3+
Web ✔️ All modern browsers

Usage

Import it:

import 'package:system_theme/system_theme.dart';
Get system accent color

Use the getter SystemTheme.accentColor.accent to get the accent color.

final accentColor = SystemTheme.accentColor.accent;

To reload the accent colors, use the method load():

await SystemTheme.accentColor.load();

You can load the colors before running the app, so the colors can't be wrong at runtime:

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await SystemTheme.accentColor.load();
  runApp(MyApp());
}
Configure a fallback accent color

To avoid unexpected outcomes at runtime, it's recommended to configure your own fallback color. The fallback color is used if the system is not able to provide the color.

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  SystemTheme.fallbackColor = const Color(0xFF865432);
  await SystemTheme.accentColor.load();

  runApp(MyApp());
}
Listen to changes on the system accent color

To simply listen to changes on the system accent color, use the SystemTheme.onChange stream:

SystemTheme.onChange.listen((event) {
  debugPrint('Accent color changed to ${event.accentColor}');
});

Alteratively, you can the SystemThemeBuilder widget to listen to changes on the system accent color:

SystemThemeBuilder(
  builder: (context, color) {
    return ColoredBox(
      color: color.accent, // Automatically updates when system theme changes
      child: const Center(
        child: Text('System Accent Color'),
      ),
    );
  },
);
Notes

On iOS 14 and later, this is the application's SwiftUI accent color (for example, the accent configured in the app's asset catalog), or the platform's app-level default when none is configured. Unlike Windows and macOS, iOS does not expose an equivalent global user-selected system accent color. If the app accent is unavailable or cannot be converted, the existing fallback or last loaded palette is retained. iOS does not automatically report accent changes; call load() to refresh it.

Contribution

See native testing for platform test commands and manual verification steps.

Feel free to open an issue if you find an error or make pull requests.

Acknowlegments

카테고리

의존성

의존성 목록 1 개

  • system_theme_web^0.0.5

소스 저장소

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