How to find Days in Current Month in Flutter Code?




How to find Days in Current Month in Flutter Code?

Hi friends,

Today our leading topic is how to find days in current month in flutter code?. you can understand a concept of get days in current month in flutter. step by step explain flutter get days of current month. this example will help you current month get day in flutter. Let's see bellow example month get day in flutter example.

I will give you simple Example of How to find Days in Current Month in Flutter Code?

Let's get started with how to get days in current month in flutter.

So let's see bellow example:

Step 1: Create Flutter Project

Follow along with the setup, you will be creating an Flutter app.

$flutter create flutter_get_days_of_current_month_tutorial

Navigate to the project directory:

$cd flutter_get_days_of_current_month_tutorial

Step 2: Main File

Create a main.dart file in the lib directory

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {


Widget build(BuildContext context) {

return MaterialApp(

home: Scaffold(

appBar: AppBar(

title: Text('Get Days for Current Month')


body: Center(

child: GetDate()






class GetDate extends StatefulWidget {

_GetDateState createState() => _GetDateState();


class _GetDateState extends State {

String finalDate = '';

String finalDay = '';


final now =;

var dateParse = new DateTime(now.year, now.month + 1, 0);


var formattedDate = "${dateParse.month}";

var formattedDay = "${}";

setState(() {

finalDate = formattedDate.toString() ;

finalDay = formattedDay.toString() ;




Widget build(BuildContext context) {

return Scaffold(

body: Center(

child: Column(


children: [


padding: EdgeInsets.all(8.0),

child :

Text("Month = $finalDate / Day = $finalDay", style: TextStyle(fontSize: 20), textAlign:,)



onPressed: getCurrentDate,


textColor: Colors.white,

padding: EdgeInsets.fromLTRB(10, 10, 10, 10),

child: Text('Click Here To Get Days for Current Month'),







Step 3: Run this Debug App


I hope it will help you....