Flutter Heroes
26.1K subscribers
272 photos
2 videos
31.1K links
Download Telegram
New post on /r/flutterdev subreddit:

Experience of the Flutter community
What is the depth of experience of developers in the Flutter community above and beyond Flutter?How many years of experience do you have in IT.View Poll

February 15, 2022 at 09:22AM by bsutto
https://ift.tt/FVOwMSf
New post on /r/flutterdev subreddit:

Feedback needed on in-app purchase implementation
Hey everyone! I implemented in-app purchases in Flutter. I used the official plugin in_app_purchase. I would like to be sure that I did everything correctly. Any feedback is very much appreciated! Following is what I did:1) I load all products from store:
final isAvailable = InAppPurchase.instance.isAvailable(); if(isAvailable){ final response = await IAPInstance.queryProductDetails(skis.toSet()); products.value = response.productDetails; } 
2) Then I start listening to the purchaseUpdated stream
 void _listenToPurchaseUpdated( List<PurchaseDetails> purchaseDetailsList, ) async { if (purchaseDetailsList.isEmpty) { return; } final purchaseDetails = purchaseDetailsList.first; if (purchaseDetails.status == PurchaseStatus.pending) { // PENDING } else { if (purchaseDetails.status == PurchaseStatus.error) { // HANDLE ERROR } else if (purchaseDetails.status == PurchaseStatus.purchased || purchaseDetails.status == PurchaseStatus.restored) { final token = purchaseDetails.verificationData.serverVerificationData; final productId = purchaseDetails.productID; // Here I check if token is valid, and if it is, I update user data in DB final isValid = await checkIsTokenValid(productId, token); if (isValid) { // Show dialog, that purchase was completed successfully if (purchaseDetails.pendingCompletePurchase) { // QUESTION_1: when purchase status is restored, pendingCompletePurchase is always "false". I don't need it to call when purchase is autorenewed? await IAPInstance.completePurchase(purchaseDetails); } } else { // HANDLE ERROR } } } } final Stream purchaseUpdated = IAPInstance.purchaseStream; _subscription = purchaseUpdated.listen((purchaseDetailsList) { _listenToPurchaseUpdated(purchaseDetailsList); }, onDone: () { print('On done callback called'); _subscription.cancel(); // QUESTION_2: Why I cancel subscription here? Is it necessary? }, onError: (error) { // handle error here. print('Error callback called: $error'); }); 
3) When the user wants to buy a subscription, I do this:
final PurchaseParam purchaseParam = PurchaseParam(productDetails: details); await IAPInstance.buyNonConsumable(purchaseParam: purchaseParam); 
It will fire an event and the stream callback will be executed.4) The biggest question is about auto-renewal:4.1) When user is outside of app, and the subscription is renewed, how can I detect it and update in my DB? (Both for iOS and Android). My solution is to call IAPInstance.restorePurchase() when app is opened the first time. This will fire purchaseUpdated callback with "restored" purchase status, and then I do my validation with backend, which will check the token and then change user subscription expiration date in my DB. But when I check purchaseDetails.pendingCompletePurchase, it always returns false, when status is restored. Shouldn't I call completePurchase() when purchase is restored? Am I doing it correctly?4.2) When the user is in foreground, i.e. in the application, and subscription expires and renewed, purchaseUpdated callback is not called :(( What to do here? Check expiration time on app open and set timer for calling IAPInstance.restorePurchase()? I think this will also fire the purchaseUpdated callback with "restored" purchase status.P.S. In testing mode, monthly subscription duration is 5 minute, and when I don't open app long time, when I come back, there is no subscription. Is it OK? Is it only because of my test card?Thank you very much!

February 15, 2022 at 11:59AM by hmarat
https://ift.tt/ugOl8PX
New post on /r/flutterdev subreddit:

How to my alarm clock app functioning/working?
Hi, I'm a beginner and want to ask how to make an alarm app functioning? I'hv made the UI with canvas. But I'm still not able to find how to make it working, how to trigger the alarm at a set time.How to write the backend? can we do it in dart? or I'll need to learn kotlin?Thanks

February 15, 2022 at 12:53PM by Logical_Clothes_1089
https://ift.tt/TGNHOqB
New post on /r/flutterdev subreddit:

Any thoughts on the WidgetView pattern ?
Hi,I have been using Provider + change notifier for state management for a while and it was great. Now that I started making biggers projects I think separating the UI from the logic has become a little bit harder since provider always require to have a context.I recently found this article about WidgetView pattern and it seems to work well with provider, although I haven't found much documentation/videos about it.https://blog.gskinner.com/archives/2020/02/flutter-widgetview-a-simple-separation-of-layout-and-logic.htmlI have tried Bloc in the past and I didn't really understand his full potential because I was applying it to small projects. Now I dont know if I should start using bloc or keep provider + change notifier + widgetview.The main advantage of bloc would be to have a lot of documentation and lots of people using it while the advantage of widgetview would be being able to still using provider and reduce the boilerplate.Do you guys have any thought about this? have anyone tried to use widgetview ?Thank you so much

February 15, 2022 at 01:23PM by ZuppaSalata
https://ift.tt/dXBqRyN
New post on /r/flutterdev subreddit:

<b>Pass File from child back to parent</b>
I'm using Image Picker on a file that looks like this `import 'dart:io';` class EditImage extends StatefulWidget { const EditImage({Key? key}) : super(key: key);@override State<EditImage> createState() => _EditImageState(); }class _EditImageState extends State<EditImage> { File? image; Future pickImage() async { try { final image = await ImagePicker().pickImage(source: ImageSource.gallery); if (image == null) return;<pre> final imageTemporary = File(image.path); setState(() { this.image = imageTemporary; }); } on PlatformException catch (e) { // ignore: avoid_print print("Failed to pick image:$e"); } </pre>}Future pickCamera() async { try { final image = await ImagePicker().pickImage(source: ImageSource.camera); if (image == null) return;<pre> final imageTemporary = File(image.path); setState(() { this.image = imageTemporary; }); } on PlatformException catch (e) { // ignore: avoid_print print("Failed to pick image:$e"); } </pre>}@override Widget build(BuildContext context) { return Padding( padding: EdgeInsets.only(left: 0.15.sw), child: GestureDetector( onTap: () { if (image == null) { showDialog<void>( context: context, barrierDismissible: false, // user must tap button! builder: (BuildContext context) { return AlertDialog( title: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, // ignore: prefer_const_literals_to_create_immutables children: [ const Text( 'Choose Image', style: TextStyle(), ), IconButton( onPressed: () { Navigator.pop(context); }, icon: Icon( Icons.close, size: 20.sp, color: const Color(0xFF000000), ), ) ], ), content: SingleChildScrollView( child: ListBody( children: const <Widget>[ Text( 'Choose a profile Picture to upload', style: TextStyle(), ), ], ), ), actions: <Widget>[ TextButton( child: const Text( 'Camera', style: TextStyle( fontSize: 12, color: Colors.black, fontWeight: FontWeight.bold, ), ), onPressed: () { pickCamera(); Navigator.pop(context); }, ), TextButton( child: const Text( 'Gallery', style: TextStyle( fontSize: 12, color: Colors.black, fontWeight: FontWeight.bold, ), ), onPressed: () { pickImage(); Navigator.pop(context); }, ), ], ); }, ); } }, child: SizedBox( width: 190.w, height: 125.h, child: Stack( children: [ Positioned( bottom: 0, right: 5, child: ConstrainedBox( constraints: BoxConstraints.tightFor(width: 70.w, height: 15.h), child: ElevatedButton( style: ElevatedButton.styleFrom( elevation: 0, primary: Colors.green[700], ), onPressed: () { if (image != null) { showDialog<void>( context: context, barrierDismissible: false, // user must tap button! builder: (BuildContext context) { return AlertDialog( title: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, // ignore: prefer_const_literals_to_create_immutables children: [ const Text( 'Choose Image', style: TextStyle(), ), IconButton( onPressed: () { Navigator.pop(context); }, icon: Icon( Icons.close, size: 20.sp, color: const Color(0xFF000000), ), ) ], ), content: SingleChildScrollView( child: ListBody( children: const <Widget>[ Text( 'Choose a profile Picture to upload', style: TextStyle(), ), ], ), ), actions: <Widget>[ TextButton( child: const Text( 'Camera', style: TextStyle( fontSize: 12, color: Colors.black, fontWeight: FontWeight.bold, ), ), onPressed: () { pickCamera(); Navigator.pop(context); }, ), TextButton( child: const Text( 'Gallery', style: TextStyle( fontSize: 12, color: Colors.black, fontWeight: FontWeight.bold, ), ), onPressed: () { pickImage(); Navigator.pop(context); }, ), ], ); }, ); } }, child: const Align( alignment: Alignment.topRight, child: Text( '+EDIT', textAlign: TextAlign.right, style: TextStyle( fontSize: 12, color: Color(0xff0ced10), fontWeight: FontWeight.bold), ), ), ), ), ), Container( height: 125.h, width: 125.w, clipBehavior: Clip.antiAlias, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(15.r), border: Border.all(color: const Color(0xff0ced10), width: 2), boxShadow: [ BoxShadow( color: Colors.black, offset: const…
New post on /r/flutterdev subreddit:

Why is immutability important? (Riverpod versus Provider)
Sorry, I am coming from C, so declarative programming is new to me. I don't understand why we have to make the class immutable for Riverpod. Everyone says imutablity is important, but I am confused on exactly why if we could just have read-only variables to enforce changes from the interface only. Having a separate notifier and class declaration seems very boilerplate to me and inefficient with the copy. Sorry, I really know very little about this because, at my job, I use C for simple embedded systems that control via a while(1). The only threading I understand is an interrupt of 2 levels of priority.Please let me know where I should move this question if it is inappropriate for this subreddit.

February 15, 2022 at 05:14PM by whitemagehealing
https://ift.tt/LovMaC9
New post on /r/flutterdev subreddit:

I wrote a library so you don't have to deal with Nested Hell anymore.
https://ift.tt/hZuTc7P

February 15, 2022 at 07:21PM by SaltyAom
https://ift.tt/Ntug8Xi
New post on /r/flutterdev subreddit:

EventChannel vs MethodChannel for plugins
I know that MethodChannels are for invoking methods, and EventChannels are for streaming data. Is there a performance difference between the two? I have plugins that use MethodChannels for sending data that could be done over EventChannels. I'm wondering if it's worth the effort to switch them over.

February 15, 2022 at 10:17PM by Rexios80
https://ift.tt/GdotQ90
New post on /r/flutterdev subreddit:

Has anyone had success with BLE Beacons in flutter?
Looking for package and general advice.I’d really like to use the OpenBeacon format.I need something I can get data for in IOS and Android. IOS likes to make it impossible to discover beacons but I’ll know what my UUIDs are upfront. OpenBeacon?IOS seems to have a ProximityUUID function that you pass a UUID to and the OS keeps an eye out for it. Does Android have the same?I assume there is a way to “register” a UUID in a flutter package so that I don’t need to manually BLE scan for beacons?Has anyone had success with this in a background mode? I assume I would need to be in background, that if the app is off, the beacon is entirely off/unregistered as well? Or can the beacon presence start the App?Any other gotchas to watch for?

February 16, 2022 at 07:14AM by BigTechCensorsYou
https://ift.tt/Je8oUBX
New post on /r/flutterdev subreddit:

Flutter development on macbook aire m1 8gigs ram.
I was leaning flutter for about 6 months now, I was doing it on a core 2 dou and a 4gb ram and HDD so it was like coding in hell.after a long time of saving I have now 1500$ and I want to buy a new laptop.I'm considering a base model of MBK air m1 with 8gb memory "1450$ with taxes. really sucks I know :( "I'm not going to upgrade for at least 2 ~ 4 years (only if I managed to get a well paid job before that time cause I'm currently on 250$ a month)so I need to get the most of this 1500$what's your thoughts on the MBA base model? like an emulator and a simulator and 1 docker container and some firefox tabs.some people said that I can get a lot more better laptop with that 1500$ and then I can install Open Core or a hackintosh but I'm note sure about that.please I want some advice from people who actually using MBK m1 with 8 gigs and not some random opinions. because this is the savings of my life and I'm willing to make the most of it.

February 16, 2022 at 10:14AM by HasanMHallak
https://ift.tt/afYCzT3