本文介绍了如何在Flutter中使用```DateTime```显示月份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个日历,要在日历上方显示月份。反正有只显示当前月份吗?



(贷方为

解决方案

  1. 获取国际依赖从这里。

  2. 通过添加导入依赖项



  import'package:intl / intl.dart'; 
列出月份= ['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov ','dec'];
var now = new DateTime.now();
current_mon = now.month;
print(months [current_mon + 1]);


I have a calendar where i want to display the month above the calendar. Is there anyway to display only the current month?

(credits to https://github.com/adamstyrc/ for the image)

it should look like this :

解决方案
  1. Get intl dependency from here pubdev-intl.
  2. Import the dependency by adding it to pubspec.yaml.
import 'package:intl/intl.dart';
List months = ['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'];
var now = new DateTime.now();
current_mon = now.month;
print(months[current_mon+1]);

这篇关于如何在Flutter中使用```DateTime```显示月份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 02:49