onepicker 0.1.6 copy "onepicker: ^0.1.6" to clipboard
onepicker: ^0.1.6 copied to clipboard

Introducing our innovative data picker called OnePicker, a powerful tool that allows you to access a wide range of data effortlessly.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:onepicker/onepicker.dart';
import 'package:intl/intl.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'One Picker',
      theme: ThemeData(
        primarySwatch: Colors.green,
        primaryColor: Colors.green,
      ),
      home: const MyHomePage(title: 'One Picker'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);
  final String title;
  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  String dateSeleted = " - ";
  String dateFromSeleted = " - ";
  String dateToSeleted = " - ";
  String countryFlagSeleted = " - ";
  String countryCodeSeleted = " - ";
  String countryNameSeleted = " - ";

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            Text(
              'Selected Date: $dateSeleted',
              style: Theme.of(context).textTheme.titleLarge,
              textAlign: TextAlign.center,
            ),
            const SizedBox(height: 10),
            GestureDetector(
              onTap: (){
                OnePicker().date(
                    context,
                    selectedColor: Colors.green,
                    bgColor: Colors.white,
                    onTap: (value){
                      dateSeleted = DateFormat('yyyy-MM-dd') .format(value).toString();
                      setState(() {});
                    }
                );
              },
              child: Container(
                  padding: const EdgeInsets.all(10),
                  decoration: BoxDecoration(
                      border: Border.all(
                          color: Colors.green,
                          width: 4
                      ),
                      borderRadius: const BorderRadius.all(Radius.circular(50))
                  ),
                  child: const Text(
                    'Date Picker',
                    style: TextStyle(color: Colors.green, fontSize: 20, fontWeight: FontWeight.bold),
                    textAlign: TextAlign.center,
                  )
              ),
            ),

            const SizedBox(height: 20),

            Text(
              'Selected Date  Range: $dateFromSeleted to $dateToSeleted',
              style: Theme.of(context).textTheme.titleLarge,
              textAlign: TextAlign.center,
            ),
            const SizedBox(height: 10),
            GestureDetector(
              onTap: (){
                OnePicker().dateRange(
                    context,
                    onTap: (from, to){
                      dateFromSeleted = DateFormat('yyyy-MM-dd') .format(from).toString();
                      dateToSeleted = DateFormat('yyyy-MM-dd') .format(to).toString();
                      setState(() {});
                    }
                );
              },
              child: Container(
                  padding: const EdgeInsets.all(10),
                  decoration: BoxDecoration(
                      border: Border.all(
                          color: Colors.green,
                          width: 4
                      ),
                      borderRadius: const BorderRadius.all(Radius.circular(50))
                  ),
                  child: const Text(
                    'Date Range Picker',
                    style: TextStyle(color: Colors.green, fontSize: 20, fontWeight: FontWeight.bold),
                    textAlign: TextAlign.center,
                  )
              ),
            ),
            const SizedBox(height: 20),
            Text(
              'Selected Country'
                  '\n Flag: $countryFlagSeleted'
                  '\n Code: $countryCodeSeleted'
                  '\n Name: $countryNameSeleted'
                  '',
              style: Theme.of(context).textTheme.titleLarge,
              textAlign: TextAlign.left,
            ),
            const SizedBox(height: 10),
            GestureDetector(
              onTap: (){
                OnePicker().country(
                    context,
                    onTap: (value){
                      countryFlagSeleted = value.flag;
                      countryCodeSeleted = value.code;
                      countryNameSeleted = value.name;
                      setState(() {});
                    }
                );
              },
              child: Container(
                  padding: const EdgeInsets.all(10),
                  decoration: BoxDecoration(
                      border: Border.all(
                          color: Colors.green,
                          width: 4
                      ),
                      borderRadius: const BorderRadius.all(Radius.circular(50))
                  ),
                  child: const Text(
                    'Country Picker',
                    style: TextStyle(color: Colors.green, fontSize: 20, fontWeight: FontWeight.bold),
                    textAlign: TextAlign.center,
                  )
              ),
            ),
          ],
        ),
      ),
    );
  }
}
5
likes
140
points
47
downloads

Publisher

verified publisherakurupela.com

Weekly Downloads

Introducing our innovative data picker called OnePicker, a powerful tool that allows you to access a wide range of data effortlessly.

Repository (GitHub)
View/report issues

Topics

#onepicker #date-picker #date-range-picker #county-picker #picker

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, intl

More

Packages that depend on onepicker