Skip to content

imaachman/Flutter-Calendar-Package

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

calendar_package

A widget that can be added like a container that which navigates to a calendar page that can select 2 different dates. Useful in apps to book flight/train tickets or book hotel rooms. Works on iOS, Android, Web, and MacOS.

You can always star this repo to support the project.

Screenshots

<img src = "SS1.png", height = "300em" /> <img src = "SS1.png", height = "300em" />

Usage

[Example] (https://github.com/imaachman/Flutter-Calendar-Package/blob/master/example/Example.dart)

To use this package:

    dependencies:
        flutter:
            sdk: flutter
        calendar_package:

How to use

// DateSelectionWidget() can only be used with stateful widgets to support state changes in dates

class HomePage extends StatefulWidget {  
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {

    // to access the dates an instance of CalendarBloc class should be made

  final CalendarBloc _calendarBloc = CalendarBloc();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      floatingActionButton: FloatingActionButton(
        onPressed: (){
            
            // day, month and year can be accessed by calling calendarList which :- index 0 is startDate and index 1 is endDate

          print(_calendarBloc.calendarList[0].day);
          print(_calendarBloc.calendarList[0].month); 
          print(_calendarBloc.calendarList[0].year);
          print(_calendarBloc.calendarList[1].day); 
          print(_calendarBloc.calendarList[1].month); 
          print(_calendarBloc.calendarList[1].year);
        },
        backgroundColor: Colors.red,
      ),
      appBar: AppBar(),
      body: DateSelectionWidget() //DateSelectionWidget() returns a container and should be used like one!
    );
  }

  // if you want to use just the calendar page, you can use the CalendarPage() class

Getting Started

This project is a starting point for a Dart package, a library module containing code that can be shared easily across multiple Flutter or Dart projects.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

About

A flutter package to add a calendar to your booking app.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages