Skip to content

Instantly share code, notes, and snippets.

View coderspacedev's full-sized avatar
🤔
I may be slow to respond.

Coder Space coderspacedev

🤔
I may be slow to respond.
View GitHub Profile
class PaymentScreen extends StatefulWidget {
const PaymentScreen({Key? key}) : super(key: key);
@override
State<StatefulWidget> createState() {
return _PaymentScreenState();
}
}
class _PaymentScreenState extends State<PaymentScreen> {
billingHelper!.checkRestore();
billingHelper!.buyProduct(Platform.isAndroid ? 'android.test.purchased' : 'weekly');
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(
Future<void> initPrice() async {
await billingHelper?.getPrice(Platform.isAndroid ? 'android.test.purchased' : 'weekly');
}
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);
}
dependencies:
flutter_billing_plugin: ^0.0.9
@coderspacedev
coderspacedev / VideoView
Created September 23, 2021 07:06
Play video from raw folder
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() {