This file contains 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 PaymentScreen extends StatefulWidget { | |
const PaymentScreen({Key? key}) : super(key: key); | |
@override | |
State<StatefulWidget> createState() { | |
return _PaymentScreenState(); | |
} | |
} | |
class _PaymentScreenState extends State<PaymentScreen> { |
This file contains 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
billingHelper!.checkRestore(); |
This file contains 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
billingHelper!.buyProduct(Platform.isAndroid ? 'android.test.purchased' : 'weekly'); |
This file contains 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
void initListeners() { | |
billingHelper?.setPurchaseUpdateHandler((status, value) async { | |
switch (status) { | |
case 'success': | |
if (kDebugMode) { | |
print('$status : $value'); | |
ScaffoldMessenger.of(context).showSnackBar(SnackBar( | |
duration: const Duration(seconds: 1), | |
backgroundColor: Utils.getPrimaryColor(), | |
content: Text( |
This file contains 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
Future<void> initPrice() async { | |
await billingHelper?.getPrice(Platform.isAndroid ? 'android.test.purchased' : 'weekly'); | |
} |
This file contains 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
List<String> productIds = [Platform.isAndroid ? 'android.test.purchased' : 'weekly']; | |
Future<void> initBilling() async { | |
billingHelper = FlutterBillingPlugin(); | |
//pass secret key for iOS development auto renewal | |
await billingHelper?.init(productIds, "a59d0387edeb46e594fc00be5463ab7f", false); | |
} |
This file contains 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
dependencies: | |
flutter_billing_plugin: ^0.0.9 |
This file contains 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
private void playVideo() { | |
String path = "android.resource://" + getPackageName() + "/" + R.raw.video; | |
binding.videoView.setVideoURI(Uri.parse(path)); | |
binding.videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { | |
@Override | |
public void onCompletion(MediaPlayer mp) { | |
} | |
}); | |
binding.videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { |