flutter_khmer_chankitec 0.0.1 copy "flutter_khmer_chankitec: ^0.0.1" to clipboard
flutter_khmer_chankitec: ^0.0.1 copied to clipboard

A Flutter plugin for Khmer lunar calendar (Chhankitek/ចន្ទគតិ) calculations. Convert Gregorian dates to Khmer lunar dates with full support for Buddhist calendar features including Sila days detection.

example/lib/main.dart

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

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Khmer Chankitec Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Khmer Lunar Calendar Demo'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  late KhmerLunarDate _lunarDate;

  @override
  void initState() {
    super.initState();
    // Get current date in Khmer lunar calendar
    _lunarDate = Chhankitek.now();
  }

  void _refreshDate() {
    setState(() {
      _lunarDate = Chhankitek.now();
    });
  }

  @override
  Widget build(BuildContext context) {
    final now = DateTime.now();
    
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: SingleChildScrollView(
          padding: const EdgeInsets.all(20.0),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              const Text(
                'Today\'s Date',
                style: TextStyle(fontSize: 28, fontWeight: FontWeight.bold),
              ),
              const SizedBox(height: 30),
              
              // Gregorian Date
              Card(
                elevation: 4,
                child: Padding(
                  padding: const EdgeInsets.all(20.0),
                  child: Column(
                    children: [
                      const Text(
                        'Gregorian Calendar',
                        style: TextStyle(fontSize: 18, fontWeight: FontWeight.w600),
                      ),
                      const SizedBox(height: 10),
                      Text(
                        '${now.day}/${now.month}/${now.year}',
                        style: const TextStyle(fontSize: 24),
                      ),
                    ],
                  ),
                ),
              ),
              
              const SizedBox(height: 20),
              
              // Khmer Lunar Date
              Card(
                elevation: 4,
                color: Colors.deepPurple.shade50,
                child: Padding(
                  padding: const EdgeInsets.all(20.0),
                  child: Column(
                    children: [
                      Text(
                        'Khmer Lunar Calendar',
                        style: TextStyle(
                          fontSize: 18,
                          fontWeight: FontWeight.w600,
                          color: Colors.deepPurple.shade700,
                        ),
                      ),
                      const SizedBox(height: 15),
                      Text(
                        _lunarDate.toString(),
                        style: const TextStyle(fontSize: 16),
                        textAlign: TextAlign.center,
                      ),
                      const SizedBox(height: 15),
                      if (_lunarDate.isSilaDay)
                        Container(
                          padding: const EdgeInsets.symmetric(
                            horizontal: 12,
                            vertical: 6,
                          ),
                          decoration: BoxDecoration(
                            color: Colors.orange.shade100,
                            borderRadius: BorderRadius.circular(20),
                            border: Border.all(color: Colors.orange.shade700),
                          ),
                          child: Text(
                            'ថ្ងៃសីល (Sila Day)',
                            style: TextStyle(
                              color: Colors.orange.shade900,
                              fontWeight: FontWeight.bold,
                            ),
                          ),
                        ),
                    ],
                  ),
                ),
              ),
              
              const SizedBox(height: 30),
              
              ElevatedButton.icon(
                onPressed: _refreshDate,
                icon: const Icon(Icons.refresh),
                label: const Text('Refresh'),
                style: ElevatedButton.styleFrom(
                  padding: const EdgeInsets.symmetric(
                    horizontal: 30,
                    vertical: 15,
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
1
likes
0
points
432
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin for Khmer lunar calendar (Chhankitek/ចន្ទគតិ) calculations. Convert Gregorian dates to Khmer lunar dates with full support for Buddhist calendar features including Sila days detection.

Repository (GitHub)
View/report issues

Topics

#khmer #calendar #lunar-calendar #buddhist-calendar #cambodia

License

unknown (license)

Dependencies

flutter

More

Packages that depend on flutter_khmer_chankitec