flutter_appcenter 1.0.0 flutter_appcenter: ^1.0.0 copied to clipboard
微软AppCenter,支持Android/iOS 构建、测试、发布和运营统计、原生异常上报。
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:flutter_appcenter/flutter_appcenter.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String initResult = '...';
bool isEnabledForDistribute = false;
@override
void initState() {
super.initState();
initPlatformState();
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
FlutterAppCenter.init(
appSecretAndroid: 'Your Android App Secret',
appSecretIOS: 'Your iOS App Secret',
usePrivateTrack: false,
automaticCheckForUpdate: true,
updateDialog: {
'title': '更新',
'subTitle:': '有检查到新版本',
'confirm': '立即更新',
'cancel': '取消'
}
).then((res) async{
bool enable = await FlutterAppCenter.isEnabledForDistribute();
setState((){
initResult = res;
isEnabledForDistribute = enable;
});
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Futter Appcenter'),
),
body: Center(
child: Text('Running on: FlutterAppCenter v2.0.0 \nresult: $initResult \nApp Center Distribute is ${isEnabledForDistribute ? 'enable' : 'disable'}'),
),
),
);
}
}