Flutter 踩坑合集亲测有效

1,549 阅读1分钟
原文链接: blog.csdn.net

couldn’t find “libflutter.so

flutter run 的时候有问题,build 就可以打进去
//这样就可以了 
flutter run  --target-platform android-arm

flutter Could not find an option named “target-platform”.

如果没有这个可能flutter sdk把她remove 了 这个之前遇到过,解决方式是我把fluttetr sdk 分支 切到 stable(稳定版) 那个时候这个这个分支上还有

android dialog 返回键回去的问题

一般 loading 进度框 用dialog的方式,但是返回是通过Navigator.of(context).pop(); 取消
流程发起网络(showDialog)->返回键(pop 一次)->网络成功(pop 回调一次) 就会pop 两次
解决方式 是 showDialog 里面 widget WillPopScope 这个不对返回键操作就好了
import 'package:flutter/material.dart';

// ignore: must_be_immutable
class LoadingDialog extends Dialog {
  LoadingDialog({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return new Material(
        //创建透明层
        type: MaterialType.transparency, //透明类型
        child: new WillPopScope(
          onWillPop: () async {
            return Future.value(false);
          },
          child: new Center(
            //保证控件居中效果
            child: new SizedBox(
              width: 120.0,
              height: 120.0,
              child: new Container(
                decoration: ShapeDecoration(
                  shape: RoundedRectangleBorder(
                    borderRadius: BorderRadius.all(
                      Radius.circular(8.0),
                    ),
                  ),
                ),
                child: new Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: <Widget>[
                    new CircularProgressIndicator(
                      backgroundColor: Color.fromRGBO(0, 0, 0, 0),
                      valueColor: AlwaysStoppedAnimation(Colors.white),
                    ),
                  ],
                ),
              ),
            ),
          ),
        ));
  }
}

Must be compiled first into .flat file.

gradle.properties
android.enableAapt2=false