How to show data according to day, week , month ,year wise in Flutter

168 Views Asked by At

I want to use dropdown where there will be 4 options day , week , month ,year. when I tap on any of them then my data should filter day , week, month ,year wise.. i want to show my expeses acc to day,week,month,year wise.. but I am unable to do it.

I have created event's for day , week, month, year wise. but now how I can filter them and show them in main Ui

solution for above question

1

There are 1 best solutions below

0
Meghna On
                              import 'package:flutter/material.dart';
                              
                              class MyHomePage extends StatefulWidget {
                                const MyHomePage({Key? key}) : super(key: key);
                              
                                @override
                                _MyHomePageState createState() => _MyHomePageState();
                              }
                              
                              class _MyHomePageState extends State<MyHomePage> {
                                // Initial Selected Value
                                String dropdownvalue = 'Day';
                              
                                // List of items in our dropdown menu
                                var items = [
                                  'Day',
                                  'Week',
                                  'Month',
                                  "Year",
                                ];
                              
                                @override
                                Widget build(BuildContext context) {
                                  return Scaffold(
                                    appBar: AppBar(
                                      title: const Text("My HOME"),
                                    ),
                                    body: Center(
                                      child: Column(
                                        mainAxisAlignment: MainAxisAlignment.center,
                                        children: [
                                          DropdownButton(
                                            value: dropdownvalue,
                                            icon: const Icon(Icons.keyboard_arrow_down),
                                            items: items.map((String items) {
                                              return DropdownMenuItem(
                                                value: items,
                                                child: Text(items),
                                              );
                                            }).toList(),
                                            onChanged: (String? newValue) {
                                              setState(() {
                                                dropdownvalue = newValue!;
                                              });
                                            },
                                          ),
                                        ],
                                      ),
                                    ),
                                  );
                                }
                              }