schedule_controller 0.1.3+1

schedule_controller #

Perform several different tasks daily. Straightforward and useful timer. It is easy to use. Execute tasks at fixed times. Confirm scheduled tasks before starting each time, if there are tasks, timing task generation.

pub version license

Usage #

Let's explain to everyone

callback is a function that is executed every time

timeOutRunOnce is mean run once after timeout

timing means to call the callback function at every timing time. But you need to replace the [8:30AM] to [8.5]. There is no problem with the time zone, it will be automatically adjusted to the user's time.

readFn is a function to read data, you must return a value

writeFn is a function to write data

Future get(String key) async {
  SharedPreferences prefs = await SharedPreferences.getInstance();
  return prefs.get(key);
}

Future save(String key, String value) async {
  SharedPreferences prefs = await SharedPreferences.getInstance();
  prefs.setString(key, value);
}

controller = ScheduleController([
  Schedule(
    timeOutRunOnce: true,
    timing: [8, 10.5, 16, 18],
    readFn: () async => await get('schedule'),
    writeFn: (String data) async {
      debugPrint(data);
      await save('schedule', data);
    },
    callback: () {
      debugPrint('schedule');
    },
  ),
]);
controller.run();

Languages #

English 日本語 简体中文

[0.1.3+1]

  • fix TimeCalculator class convertTimeStampToDays logic

[0.1.3]

  • feat TimeCalculator class add api of convertTimeStampToDays

[0.1.2+2]

  • fix fix ScheduleData NoSuchMethodError: The method 'cast' was called on null.

[0.1.2+1]

  • docs CHANGELOG format change pubspec description

[0.1.2]

  • fix TimeCalculator dayStart, isNewDay function logic error

[0.1.1]

  • fix time zone Offset logic error

[0.1.0]

  • refactor Official suggestions for improvement

[0.0.1]

  • docs Three language documents
  • feat Perform several different tasks daily. Very simple and useful timer. It is easy to use. Execute task at fixed time. Confirm scheduled tasks before starting each time, if there are tasks, timing task generation.

example/README.md

schedule_controller_example #

import 'package:flutter/material.dart';
import 'package:schedule_controller/schedule_controller.dart';
import 'package:shared_preferences/shared_preferences.dart';

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

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

class _MyAppState extends State<MyApp> {
  ScheduleController controller;

  Future get(String key) async {
    SharedPreferences prefs = await SharedPreferences.getInstance();
    return prefs.get(key);
  }

  Future save(String key, String value) async {
    SharedPreferences prefs = await SharedPreferences.getInstance();
    prefs.setString(key, value);
  }

  @override
  void initState() {
    super.initState();
    controller = ScheduleController([
      Schedule(
        timeOutRunOnce: true,
        timing: [8, 10.5, 16, 18],
        readFn: () async => await get('schedule'),
        writeFn: (String data) async {
          debugPrint(data);
          await save('schedule', data);
        },
        callback: () {
          debugPrint('schedule');
        },
      ),
    ]);
    controller.run();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('Plugin example app')),
        body: Center(child: Text('test schedule')),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  schedule_controller: ^0.1.3+1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or 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:schedule_controller/schedule_controller.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
52
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]
76
Learn more about scoring.

We analyzed this package on Sep 10, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.0
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:schedule_controller/schedule_controller.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.22.0 <3.0.0