Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Future<void> initPlatformState() async {
- var result = await FlutterInappPurchase.initConnection;
- print('result: $result');
- // If the widget was removed from the tree while the asynchronous platform
- // message was in flight, we want to discard the reply rather than calling
- // setState to update our non-existent appearance.
- if (!mounted) return;
- // refresh items for android
- String msg = await FlutterInappPurchase.consumeAllItems;
- print('consumeAllItems: $msg');
- await _getProduct();
- }
- Future<Null> _getProduct() async {
- List<IAPItem> items = await FlutterInappPurchase.getProducts([Constants.removeAdsProductId]);
- for (var item in items) {
- print('${item.toString()}');
- this._items.add(item);
- }
- setState(() {
- this._items = items;
- });
- }
- List<Widget> _renderButton() {
- List<Widget> widgets = this._items.map((item) =>
- Column(
- children: <Widget>[
- Container(
- height: 250.0,
- width: double.infinity,
- child: Card(
- child: Column(
- children: <Widget>[
- SizedBox(height: 28.0),
- Align(
- alignment: Alignment.center,
- child: Text(language.removeAdTitle, style: Theme
- .of(context)
- .textTheme
- .display1,),
- ),
- SizedBox(height: 24.0),
- Align(
- alignment: Alignment.center,
- child: Text(language.removeAdFirstText, style: TextStyle(fontSize: 16.0, color: Colors.grey[700]),),
- ),
- Align(
- alignment: Alignment.center,
- child: Text(language.removeAdSecondText, style: TextStyle(fontSize: 16.0, color: Colors.grey[700])),
- ),
- SizedBox(height: 24.0),
- SizedBox(
- width: 340.0,
- height: 50.0,
- child: RaisedButton(
- onPressed: () => _buyProduct(item),
- shape: new RoundedRectangleBorder(
- borderRadius: new BorderRadius.circular(30.0)),
- child: Text('${language.buy} ${item.price} ${item.currency}', style: Theme.of(context).primaryTextTheme.button,),
- ),
- ),
- ],
- ),
- ),
- ),
- ],
- )
- ).toList();
- return widgets;
- }
- @override
- Widget build(BuildContext context) {
- language = AppLocalizations.of(context);
- return Column(
- children: this._renderButton(),
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement