123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- import 'dart:io';
- import 'package:device_apps/device_apps.dart' as app;
- import 'package:android_intent/android_intent.dart';
- import 'package:android_intent/flag.dart';
- import 'package:flutter/material.dart';
- import 'package:sport/utils/toast.dart';
- import 'package:sport/widgets/button_primary.dart';
- Future startRun(BuildContext context) async {
- var package = "com.ouj.hiyd";
- var componentName = "com.ouj.hiyd.SplashActivity_";
- if (Platform.isAndroid) {
- var sport = await app.DeviceApps.getApp(package);
- if(sport == null) {
- ToastUtil.show("你还没安装 Hi运动 app");
- return;
- }
- AndroidIntent intent = AndroidIntent(
- action: "android.intent.action.MAIN",
- package: package,
- componentName: componentName,
- flags: [
- Flag.FLAG_ACTIVITY_NEW_TASK
- ],
- arguments: {
- });
- intent.launch();
- }
- }
- class GameRun extends StatelessWidget {
- @override
- Widget build(BuildContext context) {
- return GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: () {},
- child: Row(
- children: <Widget>[
- Container(
- width: 50.0,
- height: 50.0,
- margin: const EdgeInsets.all(12.0),
- child: Image.asset("lib/assets/img/home_game_run.png"),
- ),
- Expanded(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Text(
- "跑步训练",
- style: Theme.of(context).textTheme.subtitle1.copyWith(fontSize: 16.0, fontWeight: FontWeight.w600),
- ),
- SizedBox(
- height: 3,
- ),
- Text("125514人在练", style: Theme.of(context).textTheme.bodyText1, maxLines: 1),
- SizedBox(
- height: 6,
- )
- ],
- ),
- ),
- Padding(
- padding: const EdgeInsets.all(12.0),
- child: PrimaryButton(
- width: 93,
- height: 35,
- content: "开始跑步",
- callback: () {
- startRun(context);
- },
- ),
- )
- ],
- ),
- );
- }
- }
|