sliver_calendar 0.1.0

  • Example
  • Installing
  • Versions
  • 68


Shows a scrolling calendar list of events. This is still relatively basic, it always assumes that the getEvents returns the entire list of calendar events (mostly ignoring the values passed into the source). It does work however :) Right now it also assumes there is an asset at assets/images/calendarheader.png which it will use to display the header and an asset at assets/images/calendarbanner.jpg which it will use for the month header.

The calendar uses slivers to display the widgets in the view and lets you scroll forward and backward through the events. The header widget will drop down and open up the days of the month, letting you select specific days as well as move back and forth between the months. By default it displays a list of events and not a day view, the day view code is all just a stub right now.

Here is how to use the calendar widget itself:

new CalendarWidget(
              initialDate: new,
              buildItem: buildItem,
              getEvents: getEvents,

How to setup a source for the calendar widget.

  List<Game> _listToShow;
  StreamSubscription<UpdateReason> _listening;

  Widget buildItem(BuildContext context, CalendarEvent event) {
    return new GameCard(_listToShow[event.index]);

  List<CalendarEvent> getEvents(DateTime start, DateTime end) {
    if (_listToShow == null) {
      _listToShow =;
    if (_listToShow == null) {
      return [];
    List<CalendarEvent> events = new List<CalendarEvent>();
    int pos = 0;
    _listToShow.forEach((Game g) => events.add(new CalendarEvent(
        instant: g.tzTime, instantEnd: g.tzEndTime, index: pos++)));
    return events;

Example of the calendar widget in action: <img src="">

Getting Started

For help getting started with Flutter, view our online documentation.

For help on editing package code, view the documentation.

[0.0.1] - May 2018

  • Add in the basics for the sliver calendar.

[0.0.3] - Jun 7rth 2018

  • Add in the date range correctly.
  • Fix up views with the same date,

[0.0.4] = Jun 10th 2018

  • Fix subscription cancel/fix up for the pub spec.
  • Fix the homepage for the calendar code.

[0.1.0] - Sep 26th 2018

  • Change the subscription model to make it more in line with how flutter normally works.


import 'package:flutter/material.dart';
import 'package:sliver_calendar/sliver_calendar.dart';
import 'package:timezone/timezone.dart';
import 'package:flutter/services.dart' show rootBundle;
import 'package:flutter_native_timezone/flutter_native_timezone.dart';
import 'dart:math';
import 'dart:typed_data';
import 'dart:async';

void main() async {
  ByteData loadedData;

  await Future.wait([
    rootBundle.load('assets/timezone/2018c.tzf').then((ByteData data) {
      loadedData = data;
      print('loaded data');
  runApp(new MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Flutter Calendar',
      theme: new ThemeData(
      home: new MyHomePage(title: 'Flutter Calendar demo'),

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;

  _MyHomePageState createState() => new _MyHomePageState();

class _MyHomePageState extends State<MyHomePage> {
  List<CalendarEvent> events = <CalendarEvent>[];
  Location loc;
  Random random = new Random();

  void initState() {

  Widget buildItem(BuildContext context, CalendarEvent e) {
    return new Card(
      child: new ListTile(
        title: new Text("Event ${e.index}"),
        subtitle: new Text("Yay for events"),
        leading: const Icon(Icons.gamepad),

  List<CalendarEvent> getEvents(DateTime start, DateTime end) {
    if (loc != null && events.length == 0) {
      TZDateTime nowTime =
      new Duration(days: 5));
      for (int i = 0; i < 20; i++) {
        TZDateTime start =
        nowTime.add(new Duration(days: i + random.nextInt(10)));
        events.add(new CalendarEvent(
            index: i,
            instant: start,
            instantEnd: start.add(new Duration(minutes: 30))));
    return events;

  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text(widget.title),
      body: new Column(
        children: <Widget>[
          new FutureBuilder<String>(
            future: FlutterNativeTimezone.getLocalTimezone(),
            builder: (BuildContext context, AsyncSnapshot<String> tz) {
              if (tz.hasData) {
                 loc = getLocation(;

                return new Expanded(
                  child: new CalendarWidget(
                    initialDate: new,
                    location: loc,
                    buildItem: buildItem,
                    getEvents: getEvents,
                        new AssetImage("assets/images/calendarheader.jpg"),
                        new AssetImage("assets/images/calendarbanner.jpg"),
              } else {
                return new Center(
                  child: new Text("Getting the timezone"),

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  sliver_calendar: ^0.1.0

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:sliver_calendar/sliver_calendar.dart';
Version Uploaded Documentation Archive
0.1.0 Sep 26, 2018 Go to the documentation of sliver_calendar 0.1.0 Download sliver_calendar 0.1.0 archive
0.0.6 Sep 6, 2018 Go to the documentation of sliver_calendar 0.0.6 Download sliver_calendar 0.0.6 archive
0.0.5 Jun 11, 2018 Go to the documentation of sliver_calendar 0.0.5 Download sliver_calendar 0.0.5 archive
0.0.4 Jun 11, 2018 Go to the documentation of sliver_calendar 0.0.4 Download sliver_calendar 0.0.4 archive
0.0.3 Jun 7, 2018 Go to the documentation of sliver_calendar 0.0.3 Download sliver_calendar 0.0.3 archive
0.0.2 May 30, 2018 Go to the documentation of sliver_calendar 0.0.2 Download sliver_calendar 0.0.2 archive
0.0.1 May 30, 2018 Go to the documentation of sliver_calendar 0.0.1 Download sliver_calendar 0.0.1 archive
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Dec 5, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.7
  • Flutter: 1.0.0


Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health issues and suggestions

Fix lib/src/calendarheader.dart. (-25 points)

Analysis of lib/src/calendarheader.dart failed with 1 error:

line 136 col 40: The argument type '(Null) → Null' can't be assigned to the parameter type '(void) → dynamic'.

Fix lib/src/calendar.dart. (-0.50 points)

Analysis of lib/src/calendar.dart reported 1 hint:

line 142 col 8: This method overrides a method annotated as @mustCallSuper in 'State', but does not invoke the overridden method.

Fix lib/src/calendarevent.dart. (-0.50 points)

Analysis of lib/src/calendarevent.dart reported 1 hint:

line 3 col 8: Unused import: 'sliverscrollviewcalendar.dart'.

Maintenance issues and suggestions

Use constrained dependencies. (-20 points)

The pubspec.yaml contains 1 dependency without version constraints. Specify version ranges for the following dependencies: timezone.

The description is too short. (-20 points)

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0 <3.0.0
flutter 0.0.0
flutter_localizations 0.0.0
flutter_native_timezone ^1.0.0 1.0.1
intl ^0.15.5 0.15.7
timezone 0.5.0-dev-3
Transitive dependencies
collection 1.14.11
meta 1.1.6
path 1.6.2
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
test any