屏幕相关

设置屏幕横屏

SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);

弹窗

showModalBottomSheet(context: context,
        isScrollControlled: true,
        enableDrag: false,
        isDismissible: false,
        builder:(_)=> const Onbording(),);
    }

在初始化时使用弹窗用delayed

Future.delayed(
      Duration.zero,(){
      showModalBottomSheet(context: context,
        isScrollControlled: true,
        enableDrag: false,
        isDismissible: false,
        builder:(_)=> const Onbording(),);
    }
    );</code></pre><p>完整代码:</p><pre><code> void initState() {
    super.initState();
    //界面build完成后执行回调函数

    Future.delayed(
      Duration.zero,(){
      showModalBottomSheet(context: context,
        isScrollControlled: true,
        enableDrag: false,
        isDismissible: false,
        builder:(_)=&gt; const Onbording(),);
    }
    );

  }

对于SharedPreferences的使用

void newversion() async{
  SharedPreferences? newversion = await SharedPreferences.getInstance();
  newversion.setString(&quot;version&quot;, version);
}</code></pre><p>可以这样异步调用</p><pre><code>  void newversionpop() async{
    bool ispop = await isversion() ;
    setState(() {
      if(ispop == false){
        Future.delayed(
            Duration.zero,(){
          showModalBottomSheet(context: context,
            isScrollControlled: true,
            enableDrag: false,
            isDismissible: false,
            builder:(_)=&gt; const Onbording(),);
        }
        );
      }
    });
}