flutter_annual_task 0.1.4

  • Readme
  • Changelog
  • Example
  • Installing
  • new68

flutter_annual_task #

flutter_annual_task #

Flutter package for displaying grid view of daily task like Github-Contributions.

Example example

Usage #

Make sure to check out example project.

AnnualTaskView(
  taskItem	// List<AnnualTaskItem>
),

Installation #

Add to pubspec.yaml:

dependencies:
  flutter_annual_task: ^0.1.3

Then import it to your project:

import 'package:flutter_annual_task/flutter_annual_task.dart';

And finally add AnnualTaskView widget in your project.

AnnualTaskView(
  taskItem	// List<AnnualTaskItem>
),

AnnualTaskItem #

AnnualTaskItem

class AnnualTaskItem {
  final DateTime date;
  final double proceeding;	// 0.0 ~ 1.0

  AnnualTaskItem(this.date, [this.proceeding = 1.0]);
  ...
}

The value of proceeding affects the opacity on the each cell of daily task.<br/>- For showing the color in visual, the minimum value of displaying is 80(max: 255).

AnnualTaskColorItem

If you want to specify color for each daily task, you can use AnnualTaskColorItem.

class AnnualTaskColorItem extends AnnualTaskItem {
  final Color color;

  AnnualTaskColorItem(
    DateTime date, {
    double proceeding = 1.0,
    this.color,
  }) : super(date, proceeding);
  ...
}

You should generate list of AnnualTaskItem(List<AnnualTaskItem>) to use this package.
Below is an example for building list of AnnualTaskItem.

//AnnualTaskItem
<your_item_list>.map(
  (item) => AnnualTaskItem(
    item.date,
    0.5,
  ),
)
.toList();

//AnnualTaskColorItem
<your_item_list>.map(
  (item) => AnnualTaskColorItem(
    item.date,
    color: <color_for_each_item>
  ),
)
.toList();

Examples #

Cell Shape #

Specify cellShape with AnnualTaskCellShape with AnnualTaskCellShape.ROUNDED_SQUARE(default), AnnualTaskCellShape.SQUARE or AnnualTaskCellShape.CIRCLE.

Square

Image
square
AnnualTaskView(
  taskItem, // List<AnnualTaskItem>
  cellShape: AnnualTaskCellShape.SQUARE,
)

Circle

Image
circle
AnnualTaskView(
  taskItem, // List<AnnualTaskItem>
  cellShape: AnnualTaskCellShape.CIRCLE,
)

AnnualTaskColorItem

Image
circle
AnnualTaskView(
  taskItemWithColor, // List<AnnualTaskColorItem>
)

Labels #

You can edit the labels of week or the labels of month.

AnnualTaskView(
  taskItem, // List<AnnualTaskItem>
  showMonthLabel: false, //default : true
  showWeekDayLabel: false, //default : true
)
Image
without labels

Custom label

Image
custom labels
AnnualTaskView(
  taskItem, // List<AnnualTaskItem>
  weekDayLabels: ['', 'Mon', '', 'Wed', '', 'Fri', ''],
  monthLabels: ['1','2','3','4','5','6','7','8','9','10','11','12'],
)

The type of weekDayLabels and monthLabels is List<String>.

  • weekDayLabels starts from Sunday.
  • default value of `weekDayLabels' is ['S', 'M', 'T', 'W', 'T', 'F', 'S'].
  • default value of monthLabels' is['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']`.
  • You can also hide the label of each items with empty String(''). But, weekDayLabels should be length of 7 and, monthLabels should be length of 12.

Styled label

Image
Styled label
AnnualTaskView(
  taskItem, // List<AnnualTaskItem>
  labelStyle: TextStyle(
    color: Colors.blueGrey,
    fontSize: 10,
    fontWeight: FontWeight.bold,
  ),	// default label style : TextStyle(fontSize: 8)
)

Props #

propstypedesc
itemsList<AnnualTaskItem>List of AnnualTaskItem
yearintdefault : DateTime.now().year
activateColorColordefault : Theme.of(context).primaryColor
emptyColorColorColor of cell with proceeding 0.0 or the day which items doesn't contain. <br/>default : Color(0xFFD0D0D0)
showWeekDayLabelboolShow the labels of week, if true.<br/>default : true
cellShapeAnnualTaskCellShapeShape of cell. One of AnnualTaskCellShape.ROUNDED_SQUARE, AnnualTaskCellShape.SQUARE or AnnualTaskCellShape.CIRCLE.<br/>default: AnnualTaskCellShape.ROUNDED_SQUARE
showMonthLabelboolShow the labels of month, if true.<br/>default : true
monthLabelsList<String>Labels of month.<br/>default: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
weekDayLabelsList<String>Labels of week.<br/>default: ['S', 'M', 'T', 'W', 'T', 'F', 'S']
labelStyleTextStyleTextStyle of labels.<br/>default: TextStyle(fontSize: 8)

[0.1.4] - Mar 8, 2020 #

  • minor bug fix
    • Set week label align to Alignment.centerRight.

[0.1.3] - Mar 2, 2020 #

  • minor bug fix.

[0.1.2] - Mar 1, 2020 #

  • Update package information.

[0.1.0] - Mar 1, 2020 #

  • Draft

example/lib/main.dart

import 'dart:math';

import 'package:flutter/material.dart';
import 'package:flutter_annual_task/flutter_annual_task.dart';

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  List<AnnualTaskItem> get taskItemsWithColor =>
      AnnualTaskItemHelper.colorItemList;

  @override
  Widget build(BuildContext context) {
    List<AnnualTaskItem> taskItems = AnnualTaskItemHelper.generateAnnualTask();
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('annual_task_view'),
        ),
        body: RefreshIndicator(
          onRefresh: () {
            setState(() {});
            return Future.delayed(Duration(milliseconds: 500));
          },
          child: SingleChildScrollView(
            child: Padding(
              padding: const EdgeInsets.all(8.0),
              child: Column(
                children: [
                  _buildSectionTitle('Default'),
                  _buildExample(
                    '',
                    AnnualTaskView(taskItems),
                  ),
                  // Examples for cellShape
                  _buildSectionTitle('Cell shape'),
                  _buildExample(
                    'square',
                    AnnualTaskView(
                      taskItems, // List<AnnualTaskItem>
                      activateColor: Colors.red,
                      cellShape: AnnualTaskCellShape.SQUARE,
                    ),
                  ),
                  _buildExample(
                    'circle',
                    AnnualTaskView(
                      taskItems, // List<AnnualTaskItem>
                      activateColor: Colors.red,
                      emptyColor: Colors.grey.withAlpha(40),
                      cellShape: AnnualTaskCellShape.CIRCLE,
                    ),
                  ),
                  _buildExample(
                    'AnnualTaskColorItem',
                    AnnualTaskView(
                      taskItemsWithColor,
                    ),
                  ),

                  // Examples for label
                  _buildSectionTitle('Labels'),
                  _buildExample(
                    'without labels',
                    AnnualTaskView(
                      taskItems, // List<AnnualTaskItem>
                      showMonthLabel: false,
                      showWeekDayLabel: false,
                    ),
                  ),
                  _buildExample(
                    'custom labels',
                    AnnualTaskView(
                      taskItems, // List<AnnualTaskItem>
                      weekDayLabels: CUSTOM_WEEKDAY_LABEL,
                      monthLabels: CUSTOM_MONTH_LABEL,
                    ),
                  ),
                  _buildExample(
                    'labels style',
                    AnnualTaskView(
                      taskItems, // List<AnnualTaskItem>
                      weekDayLabels: CUSTOM_WEEKDAY_LABEL,
                      monthLabels: CUSTOM_MONTH_LABEL,
                      labelStyle: TextStyle(
                        color: Colors.blueGrey,
                        fontSize: 10,
                        fontWeight: FontWeight.bold,
                      ),
                    ),
                  ),
                ],
              ),
            ),
          ),
        ),
      ),
    );
  }

  Widget _buildSectionTitle(String title) {
    return Padding(
      padding: const EdgeInsets.symmetric(vertical: 8.0),
      child: Text(title, style: Theme.of(context).textTheme.title),
    );
  }

  Widget _buildExample(String title, AnnualTaskView child) {
    return Column(children: [
      title?.isNotEmpty == true ? Text(title) : Container(),
      SizedBox(height: 4.0),
      child,
      Divider(),
    ]);
  }
}

const List<String> CUSTOM_WEEKDAY_LABEL = ['', 'Mon', '', 'Wed', '', 'Fri', ''];
const List<String> CUSTOM_MONTH_LABEL = [
  'Jan',
  '',
  'Mar',
  '',
  'May',
  '',
  'Jul',
  '',
  'Sep',
  '',
  'Nov',
  ''
];

class AnnualTaskItemHelper {
  static final List<AnnualTaskColorItem> colorItemList = List();
  static List<AnnualTaskItem> generateAnnualTask({int year, int sampleSize}) {
    colorItemList.clear();
    var rnd = new Random();
    year = year ?? DateTime.now().year;
    sampleSize = sampleSize ?? rnd.nextInt(200);
    sampleSize = max(40, min(365, sampleSize));
    DateTime prevDate = DateTime(year, 1, 1);
    return List.generate(sampleSize, (idx) {
      int maxDiff =
          (365 - prevDate.difference(DateTime(year, 12, 31)).inDays) ~/
              (sampleSize - idx);
      prevDate = prevDate.add(Duration(days: rnd.nextInt(maxDiff) + 1));

      colorItemList.add(
        AnnualTaskColorItem(
          prevDate,
          color: Color.fromARGB(
            255,
            rnd.nextInt(180),
            rnd.nextInt(180),
            rnd.nextInt(180),
          ),
        ),
      );
      return AnnualTaskItem(
        prevDate,
        rnd.nextDouble(),
      );
    });
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_annual_task: ^0.1.4

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_annual_task/flutter_annual_task.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
36
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
68
Learn more about scoring.

We analyzed this package on Mar 31, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Health issues and suggestions

Document public APIs. (-0.12 points)

32 out of 33 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test