gpt4 book ai didi

flutter - 如何在 Flutter 中确定星座

转载 作者:行者123 更新时间:2023-12-04 00:58:48 25 4
gpt4 key购买 nike

我怎么能用 flutter 写这个?
我已经快速制作了这个应用程序,现在我正在制作这个应用程序,这是获得黄道十二宫星座的最佳方法。谢谢你

let calendar = Calendar.current
let d = calendar.component(.day, from: date)
let m = calendar.component(.month, from: date)

switch (d,m) {
case (21...31,1),(1...19,2):
return "aquarius"
case (20...29,2),(1...20,3):
return "pisces"
case (21...31,3),(1...20,4):
return "aries"
case (21...30,4),(1...21,5):
return "taurus"
case (22...31,5),(1...21,6):
return "gemini"
case (22...30,6),(1...22,7):
return "cancer"
case (23...31,7),(1...22,8):
return "leo"
case (23...31,8),(1...23,9):
return "virgo"
case (24...30,9),(1...23,10):
return "libra"
case (24...31,10),(1...22,11):
return "scorpio"
case (23...30,11),(1...21,12):
return "sagittarius"
default:
return "capricorn"
}

最佳答案

想出了基本的解决方案。


String getZodicaSign(DateTime date) {
var days = date.day;
var months = date.month;
if (months == 1) {
if (days >= 21) {
return "Aquarius";
}else {
return "Capricorn";
}
}else if (months == 2) {
if (days >= 20) {
return "Picis";
}else {
return "Aquarius";
}
}else if (months == 3) {
if (days >= 21) {
return "Aries";
}else {
return "Pisces";
}
}else if (months == 4) {
if (days >= 21) {
return "Taurus";
}else {
return "Aries";
}
}else if (months == 5) {
if (days >= 22) {
return "Gemini";
}else {
return "Taurus";
}
}else if (months == 6) {
if (days >= 22) {
return "Cancer";
}else {
return "Gemini";
}
}else if (months == 7) {
if (days >= 23) {
return "Leo";
}else {
return "Cancer";
}
}else if (months == 8) {
if (days >= 23) {
return "Virgo";
}else {
return "Leo";
}
}else if (months == 9) {
if (days >= 24) {
return "Libra";
}else {
return "Virgo";
}
}else if (months == 10) {
if (days >= 24) {
return "Scorpio";
}else {
return "Libra";
}
}else if (months == 11) {
if (days >= 23) {
return "Sagittarius";
}else {
return "Scorpio";
}
}else if (months == 12) {
if (days >= 22) {
return "Capricorn";
}else {
return "Sagittarius";
}
}
return "";
}

关于flutter - 如何在 Flutter 中确定星座,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60373426/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com