main.dart 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import 'package:flutter/material.dart';
  2. import 'package:aj_flutter_appsp/aj_flutter_appsp_lib.dart';
  3. import 'package:aj_flutter_appsp_example/notice/notice_page.dart';
  4. import "styles.dart";
  5. import 'package:aj_flutter_appsp_example/update/version_update_page.dart';
  6. void main() => runApp(MaterialApp(
  7. home: MyApp(),
  8. theme: ThemeData(
  9. platform: TargetPlatform.iOS,
  10. ),
  11. ));
  12. class MyApp extends StatefulWidget {
  13. @override
  14. _MyAppState createState() => _MyAppState();
  15. }
  16. class _MyAppState extends State<MyApp> {
  17. @override
  18. void initState() {
  19. super.initState();
  20. _initAppSp();
  21. }
  22. _initAppSp() async {
  23. //初始化
  24. var debuggable = !bool.fromEnvironment("dart.vm.product");
  25. await AjFlutterAppSp.init(
  26. appKey: "860dc3bd5faa489bb7ab6d087f8ee6e5",
  27. host: "https://openappsp.anji-plus.com",
  28. debug: debuggable);
  29. }
  30. //跳转到版本更新
  31. snaptoVersionUpdatePage() {
  32. Navigator.push(
  33. context, MaterialPageRoute(builder: (context) => VersionUpdatePage()));
  34. }
  35. //跳转到公告样式
  36. snaptoNoticePage() {
  37. Navigator.push(
  38. context, MaterialPageRoute(builder: (context) => NoticePage()));
  39. }
  40. @override
  41. Widget build(BuildContext context) {
  42. return Scaffold(
  43. appBar: AppBar(
  44. title: const Text('移动服务平台SDK'),
  45. ),
  46. body: Column(
  47. children: <Widget>[
  48. SizedBox(
  49. height: 20,
  50. ),
  51. Center(
  52. child: Styles.getBtn(context, '版本更新', () {
  53. snaptoVersionUpdatePage();
  54. }),
  55. ),
  56. SizedBox(
  57. height: 10,
  58. ),
  59. Styles.getBtn(context, '公告样式', () {
  60. snaptoNoticePage();
  61. }),
  62. ],
  63. ),
  64. );
  65. }
  66. }