daydart 0.0.5 copy "daydart: ^0.0.5" to clipboard
daydart: ^0.0.5 copied to clipboard

With the same Day. JS API time processing library, convenient to do DateTime operation.

example/lib/main.dart

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

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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        // This is the theme of your application.
        //
        // Try running your application with "flutter run". You'll see the
        // application has a blue toolbar. Then, without quitting the app, try
        // changing the primarySwatch below to Colors.green and then invoke
        // "hot reload" (press "r" in the console where you ran "flutter run",
        // or simply save your changes to "hot reload" in a Flutter IDE).
        // Notice that the counter didn't reset back to zero; the application
        // is not restarted.
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

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

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  DayDart dayDart = DayDart('2021-02-02 23:22:11.888');
  int _counter = 0;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    // print(dayDart.isLeapYear());
    // print(dayDart.add(5, DayUnits.ms));
    // // print(dayDart.format("Hms"));
    // print(dayDart.toString());
  }

  void _incrementCounter() {
    print(dayDart.dayOfYear());
    _counter++;
    setState(() {});
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headline4,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ),
    );
  }
}
2
likes
130
points
47
downloads

Publisher

unverified uploader

Weekly Downloads

With the same Day. JS API time processing library, convenient to do DateTime operation.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

flutter, intl

More

Packages that depend on daydart