第一项:新建
-
方法一
方法二
flutter create dome1
cd dome1
flutter跳转以及传值
- 示例
//页面1
import 'Listdes.dart';
Navigator.push(
context,
MaterialPageRoute(
builder:(context)=>new Listdes(title:"nihao")
)
);
//页面2
class Listdes extends StatefulWidget {
final String title;
Listdes({this.title});
@override
_ListdesState createState() => new _ListdesState();
}
class _ListdesState extends State<Listdes> {
@override
Widget build(BuildContext context) {
return new Scaffold(
body:Center(
child:Text(widget.title),
)
);
}
}
flutter android打包
- 签名
//获取签名 并存储到D盘下的key.jks文件下
keytool -genkey -v -keystore D:\key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key
- 创建key.properties(在android文件下创建key.properties文件并添加下面内容)
storePassword=<password from previous step> //输入上一步创建KEY时输入的 密钥库 密码
keyPassword=<password from previous step> //输入上一步创建KEY时输入的 密钥 密码
keyAlias=key
storeFile=<E:/key.jks> //key.jks的存放路径
- 配置key注册
1.进入项目目录的/android/app/build.gradle文件,在android{这一行前面,加入如下代码:
def keystorePropertiesFile = rootProject.file("key.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
2.把如下代码进行替换
buildTypes {
release {
signingConfig signingConfigs.debug
}
}
替换成
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
- 生成APK
//终端执行
flutter build apk
欢迎关注【哎呦程序猿公众号】,带给你更多前端干货!