schedule_controller 0.1.3+1 copy "schedule_controller: ^0.1.3+1" to clipboard
schedule_controller: ^0.1.3+1 copied to clipboard

A task scheduler controller Performs several different tasks daily. Straightforward and useful timer.

example/lib/main.dart

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')),
      ),
    );
  }
}
10
likes
40
pub points
22%
popularity

Publisher

unverified uploader

A task scheduler controller Performs several different tasks daily. Straightforward and useful timer.

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

More

Packages that depend on schedule_controller