import 'dart:io'; import 'package:android_intent_plus/android_intent.dart'; import 'package:flutter/material.dart'; class WinbooksMigrationWidget extends StatefulWidget { final String _playStoreUrl; final String _title; const WinbooksMigrationWidget(this._title, this._playStoreUrl, {Key? key}) : super(key: key); @override WinbooksMigrationWidgetState createState() => WinbooksMigrationWidgetState(); } class WinbooksMigrationWidgetState extends State { WinbooksMigrationWidgetState(); @override void initState() { super.initState(); } @override Widget build(BuildContext context) { ThemeData themeData = Theme.of(context); TextStyle largerTextStyle = themeData.textTheme.bodyText1!.apply(fontSizeFactor: 1.4); TextStyle smallerTextStyle = themeData.textTheme.bodyText2!; AssetBundle assetBundle = DefaultAssetBundle.of(context); return Scaffold( appBar: AppBar( title: Text(widget._title), ), body: GridView.count( crossAxisCount: 1, children: [ Column(children: [ Container( margin: const EdgeInsets.all(10.0), child: Text( 'My comptaplan migre vers WinBooks Connect. Téléchargez WinBooks Connect pour continuer à envoyer vos fichiers à votre comptable', textAlign: TextAlign.center, style: largerTextStyle), ), Center( child: Container( margin: const EdgeInsets.all(10.0), child: ElevatedButton( style: ElevatedButton.styleFrom(textStyle: largerTextStyle, padding: const EdgeInsets.all(20.0)), child: Row(children: [ Image.asset('images/winbooks_connect.png', bundle: assetBundle, width: 50.0, height: 50.0), const SizedBox(width: 10), const Text('Télécharger WinBooks Connect') ]), onPressed: () async { return _onWinbooksConnectPress(); }, ), ), ), Container( margin: const EdgeInsets.all(10.0), child: Text( 'Si vous ne parvenez pas à télécharger Winbooks Connect, ou pour obtenir vos identifiants, veuillez contacter votre comptable.', textAlign: TextAlign.left, style: smallerTextStyle), ), ]) ], )); } Future _onWinbooksConnectPress() async { if (Platform.isAndroid) { AndroidIntent intent = AndroidIntent( action: 'action_view', data: widget._playStoreUrl, package: 'com.android.vending', ); return intent.launch(); } } }