flutter京东SDK插件
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

86 lines
2.3 KiB

  1. import 'package:flutter/material.dart';
  2. import 'dart:async';
  3. import 'package:flutter/services.dart';
  4. import 'package:jdsdk/jdsdk.dart';
  5. void main() => runApp(MyApp());
  6. class MyApp extends StatefulWidget {
  7. @override
  8. _MyAppState createState() => _MyAppState();
  9. }
  10. class _MyAppState extends State<MyApp> {
  11. String _platformVersion = 'Unknown';
  12. @override
  13. void initState() {
  14. super.initState();
  15. initPlatformState();
  16. }
  17. // Platform messages are asynchronous, so we initialize in an async method.
  18. Future<void> initPlatformState() async {
  19. String platformVersion;
  20. // Platform messages may fail, so we use a try/catch PlatformException.
  21. try {
  22. platformVersion = await Jdsdk.platformVersion;
  23. } on PlatformException {
  24. platformVersion = 'Failed to get platform version.';
  25. }
  26. // If the widget was removed from the tree while the asynchronous platform
  27. // message was in flight, we want to discard the reply rather than calling
  28. // setState to update our non-existent appearance.
  29. if (!mounted) return;
  30. setState(() {
  31. _platformVersion = platformVersion;
  32. });
  33. }
  34. @override
  35. Widget build(BuildContext context) {
  36. return MaterialApp(
  37. home: Scaffold(
  38. appBar: AppBar(
  39. title: const Text('Plugin example app'),
  40. ),
  41. body: Column(
  42. children: <Widget>[
  43. InkWell(
  44. onTap: ()async{
  45. //android
  46. var result= await Jdsdk.init(appKey: '', appSecret: '');
  47. print(result);
  48. },
  49. child: Center(
  50. child: Text(
  51. '测试初迟化'
  52. ),
  53. ),
  54. ),
  55. SizedBox(
  56. height: 100,
  57. ),
  58. InkWell(
  59. onTap: ()async{
  60. var result = await Jdsdk.openUrl( url: 'https://item.m.jd.com/product/100009963992.html?wxa_abtest=o&utm_user=plusmember&ad_od=share&utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=CopyURL');
  61. print(result);
  62. },
  63. child: Center(
  64. child: Text(
  65. '测试打开京东'
  66. ),
  67. ),
  68. ),
  69. ],
  70. ),
  71. ),
  72. );
  73. }
  74. }