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

패키지 상세v2.5.0

flutter_circular_slider

원형 선에서 간격을 선택하기 위한 사용자 정의 가능한 위젯입니다.

30일 다운로드
89
좋아요
80
Pub 점수
40

패키지 설치

flutter pub add flutter_circular_slider

패키지 개요

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

원형 경로를 따라 간격을 선택하기 위해 설계된 사용자 정의 가능한 Flutter 위젯입니다. 사용자가 핸들을 원형으로 회전시켜 값을 선택할 수 있는 직관적인 인터페이스를 제공하며, 볼륨 조절, 각도 선택기, 시간 선택기와 같은 설정에 적합합니다. 색상, 크기, 단계 증가량 등을 사용자 정의할 수 있으며, 부드러운 애니메이션과 반응성 있는 피드백을 지원합니다. 성능과 통합 용이성을 고려하여 제작되어 현대적인 UI 디자인에 자연스럽게 녹아들 수 있습니다.

사용 사례

  • 볼륨 또는 밝기 조절
  • 디자인 도구에서 각도 선택
  • 시간 또는 간격 선택기
  • 시각적 피드백이 있는 사용자 정의 숫자 입력
  • 인터랙티브 대시보드 요소

주요 기능

  • 순환 드래그 상호작용
  • 사용자 정의 가능한 원호 범위 및 단계
  • 부드러운 애니메이션 전환
  • 사용자 지정 가능한 색상 및 스타일
  • 반응형 터치 처리

적합한 대상

  • 반경 입력이 필요한 UI
  • 독특한 형상 요소를 찾는 디자이너
  • 아날로그 스타일의 컨트롤을 갖춘 앱
  • 인터랙티브 설정이 있는 모바일 애플리케이션
  • 재사용 가능한 원형 위젯을 원하는 개발자

고려 사항

  • 원형 상호작용 패턴으로 제한
  • 비선형 값 매핑을 위해 추가 로직이 필요할 수 있습니다
  • 매우 큰 또는 매우 작은 화면 크기에 최적화되지 않음
  • 터치 입력 정밀도에 대한 신중한 테스트가 필요합니다
  • 단일 값 선택 시나리오에 가장 적합

원본 README

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

flutter_circular_slider

Build Status License: MIT Pub

A customizable circular slider for Flutter.

Getting Started

Installation

Add


flutter_circular_slider : ^lastest_version

to your pubspec.yaml, and run

flutter packages get

in your project's root directory.

Basic Usage

Create a new project with command

flutter create myapp

Edit lib/main.dart like this:

import 'package:flutter/material.dart';

import 'package:flutter_circular_slider/flutter_circular_slider.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        backgroundColor: Colors.blueGrey,
        body: Center(
          child: Container(child: DoubleCircularSlider(100, 0, 20)),
        ));
  }
}

There are two different options:

  • SingleCircularSlider: has only one handler and can be moved either dragging the handler or just by clicking on different parts of the slider.
  • DoubleCircularSlider: has two handlers and both have to be moved by dragging them.

Basic Slider

Constructor
Parameter Default Description
divisions The number of sections in which the circle will be divided for selection.
init (Only for DoubleCircularSlider) The initial value in the selection. Has to be bigger than 0 and smaller than divisions.
end (Only for DoubleCircularSlider) The end value in the selection. Has to be bigger than 0 and smaller than divisions.
position (Only for SingleCircularSlider) The selection. Has to be bigger than 0 and smaller than divisions.
height 220.0 Height of the canvas where the slider is rendered.
width 220.0 Width of the canvas where the slider is rendered.
primarySectors 0 Number of sectors painted in the base circle. Painted in selectionColor.
secondarySectors 0 Number of secondary sectors painted in the base circle. Painted in baseColor.
child null Widget that will be inserted in the center of the circular slider.
onSelectionChange void onSelectionChange(int init, int end, int laps) Triggered every time the user interacts with the slider and changes the init and end values, and also laps.
onSelectionEnd void onSelectionEnd(int init, int end, int laps) Triggered every time the user finish one interaction with the slider.
baseColor Color.fromRGBO(255, 255, 255, 0.1) The color used for the base of the circle.
selectionColor Color.fromRGBO(255, 255, 255, 0.3) The color used for the selection in the circle.
handlerColor Colors.white The color used for the handlers.
handlerOutterRadius 12.0 The radius for the outter circle around the handler.
showRoundedCapInSelection false (Only for SingleCircularSlider) Shows a rounded cap at the edge of the selection slider with no handler.
showHandlerOutter true If true will display an extra ring around the handlers.
sliderStrokeWidth 12.0 The stroke width for the slider (thickness).
shouldCountLaps false If true, onSelectionChange will also return the updated number of laps.
Use Cases
Move complete selection

Move Selection

Single Handler

Sleep Single Slider

Laps

Sleep Single Slider Laps

Sleep Double Slider Laps

Sleep Time Selection
import 'dart:math';

import 'package:flutter/material.dart';

import 'package:flutter_circular_slider/flutter_circular_slider.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: SafeArea(
      child: Container(
          decoration: BoxDecoration(
            image: DecorationImage(
              image: AssetImage('images/background_morning.png'),
              fit: BoxFit.cover,
            ),
          ),
          child: SleepPage()),
    ));
  }
}

class SleepPage extends StatefulWidget {
  @override
  _SleepPageState createState() => _SleepPageState();
}

class _SleepPageState extends State<SleepPage> {
  final baseColor = Color.fromRGBO(255, 255, 255, 0.3);

  int initTime;
  int endTime;

  int inBedTime;
  int outBedTime;

  @override
  void initState() {
    super.initState();
    _shuffle();
  }

  void _shuffle() {
    setState(() {
      initTime = _generateRandomTime();
      endTime = _generateRandomTime();
      inBedTime = initTime;
      outBedTime = endTime;
    });
  }

  void _updateLabels(int init, int end) {
    setState(() {
      inBedTime = init;
      outBedTime = end;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Column(
      mainAxisAlignment: MainAxisAlignment.spaceEvenly,
      children: [
        Text(
          'How long did you stay in bed?',
          style: TextStyle(color: Colors.white),
        ),
        DoubleCircularSlider(
          288,
          initTime,
          endTime,
          height: 260.0,
          width: 260.0,
          primarySectors: 6,
          secondarySectors: 24,
          baseColor: Color.fromRGBO(255, 255, 255, 0.1),
          selectionColor: baseColor,
          handlerColor: Colors.white,
          handlerOutterRadius: 12.0,
          onSelectionChange: _updateLabels,
          sliderStrokeWidth: 12.0,
          child: Padding(
            padding: const EdgeInsets.all(42.0),
            child: Center(
                child: Text('${_formatIntervalTime(inBedTime, outBedTime)}',
                    style: TextStyle(fontSize: 36.0, color: Colors.white))),
          ),
        ),
        Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [
          _formatBedTime('IN THE', inBedTime),
          _formatBedTime('OUT OF', outBedTime),
        ]),
        FlatButton(
          child: Text('S H U F F L E'),
          color: baseColor,
          textColor: Colors.white,
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(50.0),
          ),
          onPressed: _shuffle,
        ),
      ],
    );
  }

  Widget _formatBedTime(String pre, int time) {
    return Column(
      children: [
        Text(pre, style: TextStyle(color: baseColor)),
        Text('BED AT', style: TextStyle(color: baseColor)),
        Text(
          '${_formatTime(time)}',
          style: TextStyle(color: Colors.white),
        )
      ],
    );
  }

  String _formatTime(int time) {
    if (time == 0 || time == null) {
      return '00:00';
    }
    var hours = time ~/ 12;
    var minutes = (time % 12) * 5;
    return '$hours:$minutes';
  }

  String _formatIntervalTime(int init, int end) {
    var sleepTime = end > init ? end - init : 288 - init + end;
    var hours = sleepTime ~/ 12;
    var minutes = (sleepTime % 12) * 5;
    return '${hours}h${minutes}m';
  }

  int _generateRandomTime() => Random().nextInt(288);
}

Sleep Slider

카테고리

소스 저장소

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

아직 데이터가 없습니다.