flutter_date_picker 0.1.1

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • new50

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 Flutter:


$ flutter packages get

Alternatively, your editor might support flutter packages 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.1 May 30, 2018 Go to the documentation of flutter_date_picker 0.1.1 Download flutter_date_picker 0.1.1 archive

Analysis

We analyzed this package on Jun 19, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3
  • Flutter: 0.5.4

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
0 / 100
Health:
Code health derived from static analysis. [more]
100 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
50
Learn more about scoring.

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Suggestions

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use flutter_date_picker.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
flutter 0.0.0
Transitive dependencies
collection 1.14.6 1.14.10
meta 1.1.5
sky_engine 0.0.99
typed_data 1.1.5
vector_math 2.0.6 2.0.7
Dev dependencies
flutter_test