flutter_date_picker 0.1.1

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 45

date_picker #

Cupertino styled date picker component which works on both ios and android. #


Use this date_picker component inside a bottom modal view.

Example #

For example on how to use the component repo.

Issues #

For issues, file directly in the date_picker repo.

Cupertino_date_picker

Usage #

Let's demo the basic usage

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
  int _selectedMonthIndex = 0;
  int _selectedDateIndex = 0;
  int _selectedYearIndex = 0;
  bool _extendedButtons = false;
  VoidCallback _showBottomSheetCallback;

  @override
  void initState() {
    super.initState();
    _showBottomSheetCallback = _showBottomSheet;
  }

  setMonth(int index) {
    setState(() {
      _selectedMonthIndex = index;
    });
  }

  setDate(int index) {
    setState(() {
      _selectedDateIndex = index;
    });
  }

  setYear(int index) {
    setState(() {
      _selectedYearIndex = index;
    });
  }

  void _snackBar(String text) {
    _scaffoldKey.currentState.showSnackBar(SnackBar(content: Text(text)));
  }

  _showBottomSheet() {
    final FixedExtentScrollController scrollController =
        FixedExtentScrollController(initialItem: _selectedMonthIndex);

    setState(() {
      _showBottomSheetCallback = null;
    });
    _scaffoldKey.currentState
        .showBottomSheet<Null>((BuildContext context) {
          final ThemeData themeData = Theme.of(context);
          return DatePickerComponent(
              setMonth: setMonth,
              setDate: setDate,
              setYear: setYear,
              themeData: themeData,
              scrollController: scrollController);
        })
        .closed
        .whenComplete(() {
          if (mounted) {
            setState(() {
              _showBottomSheetCallback = _showBottomSheet;
            });
          }
        });
  }

  buildFloatingActionButton() {
    if (_extendedButtons == true)
      return Container(
        width: 78.0,
        height: 32.0,
        child: FloatingActionButton(
          isExtended: true,
          onPressed: () {
            setState(() {
              _extendedButtons = false;
            });
            Navigator.of(context).pop();

            _snackBar(monthNames[_selectedMonthIndex] +
                ' ${_selectedDateIndex + 1}' +
                ' ${1950 + _selectedYearIndex}');
          },
          child: Text('Submit'),
          backgroundColor: Color.fromRGBO(0, 0, 70, 1.0),
          shape:
              RoundedRectangleBorder(borderRadius: BorderRadius.circular(5.0)),
        ),
      );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      key: _scaffoldKey,
      appBar: AppBar(
        title: Text('Date Picker'),
      ),
      body: Container(
        padding: EdgeInsets.all(10.0),
        alignment: Alignment.topCenter,
        child: RaisedButton(
          color: Colors.blue,
          child: Text('Date Picker'),
          onPressed: () {
            _showBottomSheet();
            setState(() {
              _extendedButtons = true;
            });
          },
        ),
      ),
      floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
      floatingActionButton: buildFloatingActionButton(),
    );
  }
}

0.1.1 #

  • Initial release.

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_date_picker: ^0.1.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:flutter_date_picker/flutter_date_picker.dart';
  
Version Uploaded Documentation Archive
0.1.8 Oct 31, 2018 Go to the documentation of flutter_date_picker 0.1.8 Download flutter_date_picker 0.1.8 archive
0.1.7 Oct 29, 2018 Go to the documentation of flutter_date_picker 0.1.7 Download flutter_date_picker 0.1.7 archive
0.1.6 Oct 26, 2018 Go to the documentation of flutter_date_picker 0.1.6 Download flutter_date_picker 0.1.6 archive
0.1.5 Oct 25, 2018 Go to the documentation of flutter_date_picker 0.1.5 Download flutter_date_picker 0.1.5 archive
0.1.4 Oct 25, 2018 Go to the documentation of flutter_date_picker 0.1.4 Download flutter_date_picker 0.1.4 archive
0.1.3 Oct 25, 2018 Go to the documentation of flutter_date_picker 0.1.3 Download flutter_date_picker 0.1.3 archive
0.1.2 Jul 22, 2018 Go to the documentation of flutter_date_picker 0.1.2 Download flutter_date_picker 0.1.2 archive
0.1.1 May 30, 2018 Go to the documentation of flutter_date_picker 0.1.1 Download flutter_date_picker 0.1.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
91
Health:
Code health derived from static analysis. [more]
--
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
--
Overall:
Weighted score of the above. [more]
45
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://dart.dev/dart-2#migration.

Maintenance issues and suggestions

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.