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

flutter_timetable 표지
패키지 상세v1.1.6

flutter_timetable

목록의 항목에 대한 날짜와 시간의 스케줄을 표시합니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
675
좋아요
39
Pub 점수
150

패키지 설치

flutter pub add flutter_timetable

패키지 개요

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

Flutter Timetable은 구조적이고 시각적으로 직관적인 시간표 형식으로 스케줄과 시간 기반 데이터를 표시하는 Flutter 패키지입니다. 이 패키지는 관련 날짜와 시간에 따라 리스트의 항목을 렌더링하여 이벤트, 수업 또는 약속을 표시하는 데 이상적입니다. Android, iOS, Web, macOS, Windows, Linux 등 여러 플랫폼을 지원하며 크로스플랫폼 일관성을 보장합니다. 간단함과 성능을 고려해 설계되었으며, 최소한의 설정으로 기존 Flutter 앱에 원활하게 통합됩니다. 깔끔한 레이아웃은 시간에 민감한 콘텐츠를 관리할 때 사용자 경험을 향상시킵니다.

사용 사례

  • 스케줄링 앱 인터페이스
  • 교육 앱에서의 수업 시간표
  • 이벤트 기획 대시보드
  • 시간 슬롯을 갖춘 작업 관리
  • 일일 활동 추적기

주요 기능

  • 시간 기반 항목 렌더링
  • 크로스 플랫폼 호환성
  • 사용자 정의 가능한 시간표 레이아웃
  • 날짜 및 시간 그룹화를 지원합니다
  • 이벤트 목록과의 간편한 통합

적합한 대상

  • 교육용 애플리케이션
  • 캘린더 및 스케줄링 도구
  • 생산성 및 작업 관리 앱
  • 이벤트 조정 플랫폼
  • 시간 기반 데이터 시각화

고려 사항

  • 입력 데이터는 올바른 날짜/시간 형식이 필요합니다
  • 기본 스타일링을 초과한 제한된 사용자 정의
  • 선형 시간 범위에 가장 적합
  • 복잡한 겹치는 이벤트를 처리하기 위해 추가 로직이 필요할 수 있습니다
  • 페이지네이션 없이 대용량 데이터 세트에 최적화되지 않음

원본 README

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

Timetable for Flutter

Pub Version Test status codecov

This package is a timetable for Flutter that allows developers to customize each visible UI element as needed.

Highly customizable

Every UI element display should be customizable. They are reasonable defaults, but developers should be able to override them to fit their needs. This customization is done using builder functions in the Timetable class constructor.

The Timetable class also takes a controller (TimtableController) that allows developers to manipulate the timetable using other custom functions and UI elements.

Lightweight

Intentionally avoiding dependencies makes this package lightweight, increases compatibility, and makes it easier to maintain.

Limiting the scope of this package to just the timetable widget avoids superfluous features and potential bloat. For example, instead of anticipating and building components, the TimtableController allows listeners and dispatches events, allowing developers to build more customized UI where needed.

Defaults out of the box Using customized builders and controllers
Plain old timetable Timetable with all the builders, a controller, etc,
import 'dart:math';

import 'package:flutter/material.dart';
import 'package:flutter_timetable/flutter_timetable.dart';
import 'package:intl/intl.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) => MaterialApp(
        routes: {
          '/': (context) => const TimetableScreen(),
          '/custom': (context) => const CustomTimetableScreen(),
        },
      );
}

/// Plain old default time table screen.
class TimetableScreen extends StatelessWidget {
  const TimetableScreen({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) => Scaffold(
        appBar: AppBar(
          backgroundColor: Colors.grey,
          actions: [
            TextButton(
              onPressed: () async => Navigator.pushNamed(context, '/custom'),
              child: const Row(
                mainAxisSize: MainAxisSize.max,
                children: [
                  Icon(Icons.celebration_outlined, color: Colors.white),
                  SizedBox(width: 8),
                  Text(
                    "Custom builders",
                    style: TextStyle(color: Colors.white, fontSize: 16),
                  ),
                  SizedBox(width: 8),
                  Icon(Icons.chevron_right_outlined, color: Colors.white),
                ],
              ),
            ),
          ],
        ),
        body: const Timetable(),
      );
}

/// Timetable screen with all the stuff - controller, builders, etc.
class CustomTimetableScreen extends StatefulWidget {
  const CustomTimetableScreen({Key? key}) : super(key: key);
  @override
  State<CustomTimetableScreen> createState() => _CustomTimetableScreenState();
}

class _CustomTimetableScreenState extends State<CustomTimetableScreen> {
  final items = generateItems();
  final controller = TimetableController(
    start: DateUtils.dateOnly(DateTime.now()).subtract(const Duration(days: 7)),
    initialColumns: 3,
    cellHeight: 100.0,
    startHour: 9,
    endHour: 18,
  );

  @override
  void initState() {
    super.initState();
    WidgetsBinding.instance.addPostFrameCallback((_) async {
      Future.delayed(const Duration(milliseconds: 100), () {
        controller.jumpTo(DateTime.now());
      });
    });
  }

  @override
  Widget build(BuildContext context) => Scaffold(
        appBar: AppBar(
          backgroundColor: Colors.grey,
          actions: [
            TextButton(
              onPressed: () async => Navigator.pop(context),
              child: const Row(
                children: [
                  Icon(Icons.chevron_left_outlined, color: Colors.white),
                  SizedBox(width: 8),
                  Text(
                    "Default",
                    style: TextStyle(color: Colors.white, fontSize: 16),
                  ),
                ],
              ),
            ),
            const Spacer(),
            IconButton(
              icon: const Icon(Icons.calendar_view_day),
              onPressed: () => controller.setColumns(1),
            ),
            IconButton(
              icon: const Icon(Icons.calendar_view_month_outlined),
              onPressed: () => controller.setColumns(3),
            ),
            IconButton(
              icon: const Icon(Icons.calendar_view_week),
              onPressed: () => controller.setColumns(5),
            ),
            IconButton(
              icon: const Icon(Icons.zoom_in),
              onPressed: () => controller.setCellHeight(controller.cellHeight + 10),
            ),
            IconButton(
              icon: const Icon(Icons.zoom_out),
              onPressed: () => controller.setCellHeight(controller.cellHeight - 10),
            ),
          ],
        ),
        body: Timetable<String>(
          controller: controller,
          items: items,
          cellBuilder: (datetime) => Container(
            decoration: BoxDecoration(
              border: Border.all(color: Colors.blueGrey, width: 0.2),
            ),
            child: Center(
              child: Text(
                DateFormat("MM/d/yyyy\nha").format(datetime),
                style: TextStyle(
                  color: Color(0xff000000 + (0x002222 * datetime.hour) + (0x110000 * datetime.day)).withOpacity(0.5),
                ),
                textAlign: TextAlign.center,
              ),
            ),
          ),
          cornerBuilder: (datetime) => Container(
            color: Colors.accents[datetime.day % Colors.accents.length],
            child: Center(child: Text("${datetime.year}")),
          ),
          headerCellBuilder: (datetime) {
            final color = Colors.primaries[datetime.day % Colors.accents.length];
            return Container(
              decoration: BoxDecoration(
                border: Border(bottom: BorderSide(color: color, width: 2)),
              ),
              child: Center(
                child: Text(
                  DateFormat("E\nMMM d").format(datetime),
                  style: TextStyle(
                    color: color,
                  ),
                  textAlign: TextAlign.center,
                ),
              ),
            );
          },
          hourLabelBuilder: (time) {
            final hour = time.hour == 12 ? 12 : time.hour % 12;
            final period = time.hour < 12 ? "am" : "pm";
            final isCurrentHour = time.hour == DateTime.now().hour;
            return Text(
              "$hour$period",
              style: TextStyle(
                fontSize: 14,
                fontWeight: isCurrentHour ? FontWeight.bold : FontWeight.normal,
              ),
            );
          },
          itemBuilder: (item) => Container(
            decoration: BoxDecoration(
              color: Colors.white.withAlpha(220),
              borderRadius: BorderRadius.circular(16),
              boxShadow: [
                BoxShadow(
                  color: Colors.black.withOpacity(0.2),
                  blurRadius: 4,
                  offset: const Offset(0, 2),
                ),
              ],
            ),
            child: Center(
              child: Text(
                item.data ?? "",
                style: const TextStyle(fontSize: 14),
              ),
            ),
          ),
          nowIndicatorColor: Colors.red,
          snapToDay: true,
        ),
        floatingActionButton: FloatingActionButton(
          child: const Text("Now"),
          onPressed: () => controller.jumpTo(DateTime.now()),
        ),
      );
}

/// Generates some random items for the timetable.
List<TimetableItem<String>> generateItems() {
  final random = Random();
  final items = <TimetableItem<String>>[];
  final today = DateUtils.dateOnly(DateTime.now());
  for (var i = 0; i < 100; i++) {
    int hourOffset = random.nextInt(56 * 24) - (7 * 24);
    final date = today.add(Duration(hours: hourOffset));
    items.add(TimetableItem(
      date,
      date.add(Duration(minutes: (random.nextInt(8) * 15) + 15)),
      data: "item $i",
    ));
  }
  return items;
}

카테고리

소스 저장소

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

아직 데이터가 없습니다.