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

booking_calendar 표지
패키지 상세v1.1.10

booking_calendar

앱을 통해 온라인 예약을 할 수 있는 Flutter 패키지입니다. 실시간 예약 데이터를 얻기 위해 스트림(예: Firestore 스트림)과 함께 사용하세요.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
239
좋아요
152
Pub 점수
140

패키지 설치

flutter pub add booking_calendar

패키지 개요

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

실시간 데이터 소스(예: 스트림을 통해 Firestore와 통합)와 원활하게 통합되도록 설계된 앱 내 온라인 예약 기능을 가능하게 하는 플러터 패키지입니다. 예약 관리, 가용성 표시 및 예약 이벤트를 동적으로 처리할 수 있는 사용자 정의 가능한 캘린더 인터페이스를 제공합니다. 약속 시스템, 이벤트 플래너 또는 서비스 예약 플랫폼과 같은 실시간 업데이트와 상호작용이 필요한 애플리케이션에 적합합니다. 여러 플랫폼을 지원하여 다양한 장치에서 일관된 사용자 경험을 보장합니다.

사용 사례

  • 온라인 예약
  • 이벤트 예약 시스템
  • 서비스 예약 인터페이스
  • 실시간 가용성 추적
  • 실시간 업데이트를 위한 Firestore 통합

주요 기능

  • 스트림 기반 실시간 데이터 지원
  • 크로스 플랫폼 호환성
  • 사용자 정의 가능한 캘린더 UI
  • 동적 예약 이벤트 처리
  • Firebase Firestore와의 간편한 통합

적합한 대상

  • 예약 앱을 개발하는 개발자
  • 백엔드 데이터에 Firestore를 사용하는 팀
  • 실시간 예약 업데이트가 필요한 애플리케이션
  • 다중 플랫폼 스케줄링 도구
  • 사용자 인터페이스 중심의 예약 인터페이스

고려 사항

  • 스트림 및 비동기 프로그래밍에 대한 지식이 필요합니다
  • 외부 데이터 소스(예: Firestore)에 의존합니다
  • 브랜드 일치를 위해 맞춤 스타일링이 필요할 수 있습니다
  • 성능은 스트림 데이터 부피에 따라 달라집니다
  • 기본 입력 검사 외에 제한된 내장 검증

원본 README

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

Booking Calendar Logo

Pub.dev Badge MIT License Badge Flutter Platform Badge

Booking Calendar

Want to make online bookings in your app? Then luckily you need look no further!

With a total of 4 lines, you get a working online booking system where users can track bookings in real-time.

It calculates the cases where there would be a conflict in the calendar and displays them in different colors.

You can customise your booking calendar with a number of additional parameters.

Booking Calendar Logo Booking Calendar Logo

Usage

Check the Demo Example for more Information

 Widget build(BuildContext context) {
    return BookingCalendar(
        key: key,
        ///These are the required parameters
        getBookingStream: getBookingStream,
        uploadBooking: uploadBooking,
        convertStreamResultToDateTimeRanges: convertStreamResultToDateTimeRanges,
        ///These are only customizable, optional parameters
        bookingButtonColor: bookingButtonColor,
        bookingButtonText: bookingButtonText,
        bookingExplanation: bookingExplanation,
        bookingGridChildAspectRatio: bookingGridChildAspectRatio,
        bookingGridCrossAxisCount: bookingGridCrossAxisCount,
        formatDateTime: formatDateTime,
        convertStreamResultToDateTimeRanges:
        convertStreamResultToDateTimeRanges,
        availableSlotColor: availableSlotColor,
        availableSlotText: availableSlotText,
        bookedSlotColor: bookedSlotColor,
        bookedSlotText: bookedSlotText,
        selectedSlotColor: selectedSlotColor,
        selectedSlotText: selectedSlotText,
        gridScrollPhysics: gridScrollPhysics,
        loadingWidget: loadingWidget,
        errorWidget: errorWidget,
        uploadingWidget: uploadingWidget,
        pauseSlotColor: pauseSlotColor,
        pauseSlotText: pauseSlotText,
        hideBreakTime: hideBreakTime,
        locale: locale,
        disabledDays: disabledDays,
        startingDayOfWeek: startingDayOfWeek,
    );
  }

Firebase example

After you successfully integrated Firebase to your app. How to setup Firebase with Flutter In this example, we will book sporting slots, using Firebase Firestore.

Here is the model we store in the Firebase:

import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:sport.bp/util/app_util.dart';
part 'sport_booking.g.dart';

@JsonSerializable(explicitToJson: true)
class SportBooking {
  /// The generated code assumes these values exist in JSON.
  final String? userId;
  final String? userName;
  final String? placeId;
  final String? serviceName;
  final int? serviceDuration;
  final int? servicePrice;

  //Because we are storing timestamp in Firestore, we need a converter for DateTime
  /* static DateTime timeStampToDateTime(Timestamp timestamp) {
    return DateTime.parse(timestamp.toDate().toString());
  }

  static Timestamp dateTimeToTimeStamp(DateTime? dateTime) {
    return Timestamp.fromDate(dateTime ?? DateTime.now()); //To TimeStamp
  }*/
  @JsonKey(fromJson: AppUtil.timeStampToDateTime, toJson: AppUtil.dateTimeToTimeStamp)
  final DateTime? bookingStart;
  @JsonKey(fromJson: AppUtil.timeStampToDateTime, toJson: AppUtil.dateTimeToTimeStamp)
  final DateTime? bookingEnd;
  final String? email;
  final String? phoneNumber;
  final String? placeAddress;

  SportBooking(
      {this.email,
      this.phoneNumber,
      this.placeAddress,
      this.bookingStart,
      this.bookingEnd,
      this.placeId,
      this.userId,
      this.userName,
      this.serviceName,
      this.serviceDuration,
      this.servicePrice});

  /// Connect the generated [_$SportBookingFromJson] function to the `fromJson`
  /// factory.
  factory SportBooking.fromJson(Map<String, dynamic> json) => _$SportBookingFromJson(json);

  /// Connect the generated [_$SportBookingToJson] function to the `toJson` method.
  Map<String, dynamic> toJson() => _$SportBookingToJson(this);
}

This is how the structure of the data looks like in the Firestore document: Booking Calendar Firebase model and data

So after the Firebase init, we can access the Firestore collection.

  CollectionReference bookings = FirebaseFirestore.instance.collection('bookings');

  ///This is how can you get the reference to your data from the collection, and serialize the data with the help of the Firestore [withConverter]. This function would be in your repository.
  CollectionReference<SportBooking> getBookingStream({required String placeId}) {
    return bookings.doc(placeId).collection('bookings').withConverter<SportBooking>(
          fromFirestore: (snapshots, _) => SportBooking.fromJson(snapshots.data()!),
          toFirestore: (snapshots, _) => snapshots.toJson(),
        );
  }

  ///How you actually get the stream of data from Firestore with the help of the previous function
  ///note that this query filters are for my data structure, you need to adjust it to your solution.
  Stream<dynamic>? getBookingStreamFirebase(
    {required DateTime end, required DateTime start}) {
       return ApiRepository.
                        .getBookingStream(placeId: 'YOUR_DOC_ID')
                        .where('bookingStart', isGreaterThanOrEqualTo: start)
                        .where('bookingStart', isLessThanOrEqualTo: end)
                        .snapshots(),
  }

  ///After you fetched the data from firestore, we only need to have a list of datetimes from the bookings:
  List<DateTimeRange> convertStreamResultFirebase(
    {required dynamic streamResult}) {
    ///here you can parse the streamresult and convert to [List<DateTimeRange>]
    ///Note that this is dynamic, so you need to know what properties are available on your result, in our case the [SportBooking] has bookingStart and bookingEnd property
      List<DateTimeRange> converted = []
      for (var i = 0; i < streamResult.size; i++) {
        final item = streamResult.docs[i].data();
        converted.add(DateTimeRange(start: (item.bookingStart!), end: (item.bookingEnd!)));
      }
  return converted;
}

  ///This is how you upload data to Firestore
  Future<dynamic> uploadBookingFirebase(
    {required BookingService newBooking}) async {
    await bookings
        .doc('your id, or autogenerate')
        .collection('bookings')
        .add(newBooking.toJson())
        .then((value) => print("Booking Added"))
        .catchError((error) => print("Failed to add booking: $error"));
    }
  }


/**AFTER YOU HAVE EVERY HELPER FUNCTION YOU CAN PASS THESE TO YOUR BOOKINGCALENDAR */
BookingCalendar(
    bookingService: mockBookingService,
    convertStreamResultToDateTimeRanges: convertStreamResultFirebase,
    getBookingStream: getBookingStreamFirebase,
    uploadBooking: uploadBookingFirebase,
    uploadingWidget: const CircularProgressIndicator(),
    //... other customisation properties
),

Additional information

Feel free to add issues, open PR-s and leave comments on the github repository.

"Buy Me A Coffee"

카테고리

의존성

의존성 목록 3 개

소스 저장소

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

아직 데이터가 없습니다.