mindful_minutes 0.1.2 copy "mindful_minutes: ^0.1.2" to clipboard
mindful_minutes: ^0.1.2 copied to clipboard

outdated

A Flutter plugin for saving mindful minutes to Apple Health.

example/lib/main.dart

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

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

///
class MyApp extends StatefulWidget {
  ///
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: ElevatedButton(
            onPressed: _saveMindfulMinutes,
            child: const Text('Save one mindful minute'),
          ),
        ),
      ),
    );
  }

  Future<void> _saveMindfulMinutes() async {
    final plugin = MindfulMinutesPlugin();

    final bool hasPermission = await plugin.checkPermission();
    if (!hasPermission) {
      final bool isPermissionGranted = await plugin.requestPermission();
      if (isPermissionGranted) {
        final startTime = DateTime.now();
        final endTime = startTime.subtract(const Duration(minutes: 1));
        await plugin.writeMindfulMinutes(startTime, endTime);
      }
    }
  }
}
12
likes
0
pub points
60%
popularity

Publisher

verified publisherachim.io

A Flutter plugin for saving mindful minutes to Apple Health.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on mindful_minutes