flutter - 如何在 Flutter 中确定星座

标签 flutter

我怎么能用 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/

相关文章:

dart - Flutter 在图像上绘制并缩放并移动两者

flutter - 目前有没有办法通过flutter开发window桌面程序?如果是,如何?

android - Flutter项目中 "flutter.minSdkVersion"的值在哪里初始化?

flutter - Visibility vs Offstage vs Opacity,哪个最能将 child 隐藏在小部件树中?

flutter - 如何使用 SliverAppBar 在 Flutter 中垂直居中文本/标题?

flutter - 未按预期从 await 函数返回 Future

list - 在 firestore 集合中保存从 JSON URL 获取的列表

flutter - CheckBox值,我要添加,如果用户选中checkBox,则应添加amount = amount + 18%,否则请仅添加我的代码

flutter - 如何动态更改 SliverAppBar 高度

dart - flutter 开关 - onChanged 不改变