This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ar-SA, ca, cs, da, de-DE, el, en-AU, en-CA, en-GB, en-US, es-ES, es-MX, fi, fr-CA, fr-FR, he, hi, hr, hu, id, it, ja, ko, ms, nl-NL, no, pl, pt-BR, pt-PT, ro, ru, sk, sv, th, tr, uk, vi, zh-Hans, zh-Hant |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// original code is here, this is upadated version for the new Flutter | |
// https://gist.github.com/guptahitesh121/ca7fa34d73b8b024823c85dd0c7f687d | |
import 'package:flutter/gestures.dart'; | |
import 'package:flutter/material.dart'; | |
void main() => runApp(const MyApp()); | |
class MyApp extends StatelessWidget { | |
const MyApp({Key? key}) : super(key: key); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:async'; | |
import 'package:rxdart/rxdart.dart'; | |
class CounterBloc { | |
int _counter; | |
CounterBloc() { | |
_counter = 1; | |
_actionController.stream.listen(_increaseStream); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyHomePage extends StatelessWidget { | |
CounterBloc counterBloc = CounterBloc(); | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: StreamBuilder<int>( | |
stream: counterBloc.pressedCount, | |
builder: (context, snapshot) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Example 3 for article getters&setters | |
class Person { | |
String name; | |
int birthYear; | |
bool get isAdult => (DateTime.now().year - birthYear) > 18; | |
int get age => (DateTime.now().year - birthYear); | |
set age(int val) => birthYear = (DateTime.now().year - val); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Example 1 for article getters&setters | |
class Person { | |
String name; | |
int birthYear; | |
Person(this.name, this.birthYear); | |
} | |
void main() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (Platform.isIOS) { | |
var history = await FlutterInappPurchase.getPurchaseHistory(); | |
for (var purchase in history) { | |
Duration difference = | |
DateTime.now().difference(purchase.transactionDate); | |
if (difference.inMinutes <= (duration + grace).inMinutes && | |
purchase.productId == 'SKU_OF_SUBSCRIPTION') return 'PAID_STATE_FOR_YOUR_CHOICE'; | |
} | |
return 'NOT_PAID_STATE_FOR_YOUR_CHOICE'; | |
} |