z_picker 0.0.4 copy "z_picker: ^0.0.4" to clipboard
z_picker: ^0.0.4 copied to clipboard

A time picker and item picker in Cupertino style.

example/lib/main.dart

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

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

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

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

  final String title;

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

class _MyHomePageState extends State<MyHomePage> {
  void showTimePicker() {
    showModalBottomSheet(
      barrierColor: Colors.black.withOpacity(0.2),
      backgroundColor: Colors.transparent,
      context: context,
      builder: (BuildContext context) {
        return TCRTimePicker(
          title: 'Please select the time',
          beginTime: DateTime.now().add(Duration(days: 1, hours: 1)),
          selectTime: DateTime.now().add(Duration(days: 1, hours: 13)),
          callback: (time) {
            print('item = $time');
          },
        );
      },
    );
  }

  void showItemPicker() {
    showModalBottomSheet(
      barrierColor: Colors.black.withOpacity(0.2),
      backgroundColor: Colors.transparent,
      context: context,
      builder: (BuildContext context) {
        return TCRItemPicker(
          initialIndex: 2,
          title: 'Please select the subject',
          items: ['Math', 'English', 'Chemistry', 'History'],
          callback: (index, item) {
            print('item = $item');
          },
        );
      },
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            TextButton(onPressed: showTimePicker, child: Text('TimePicker')),
            TextButton(onPressed: showItemPicker, child: Text('ItemPicker')),
          ],
        ),
      ),
    );
  }
}
1
likes
110
pub points
0%
popularity

Publisher

unverified uploader

A time picker and item picker in Cupertino style.

Repository

Documentation

API reference

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on z_picker