I am following this and this tutorial to integrate stripe payment into my flutter project. Both of these tutorials/examples reference the class StripeSource by calling its method
StripeSource.setPublishableKey("pk_test");
but this class seems to be missing from the latest stripe package for a flutter. I've added the flutter SDK using stripe_payment: ^1.0.0 in my pubspec.yaml file and other stripe classes are available.
Any help is highly appreciated :-).
Those tutorial are outdated. The library changed and now it works in a different way. Instead of using StripeSource, you should use StripePayment.
For example:
StripePayment.setOptions(StripeOptions(
publishableKey:
'YOUR_TEST_PUBLISH_KEY'));
StripePayment.paymentRequestWithCardForm(
CardFormPaymentRequest())
.catchError((e) {
print('ERROR ${e.toString()}');
}).then((paymentMethod) {
//DO SOMETHING WITH YOUR PAYMENT METHOD
});
EDIT
What matters to follow those tutorials, is to optain the 'token'. As it is not very clear and there is not a complete documentation, I want to point out that:
paymentMethod.id is equal to the token returned by StripeSource.addSource() in the old versions.
Related
I am desperately trying to figure out how to initializeApp with Flutter (not React Native).
I know about the functions to use, but I can not find the firebaseConfig I need to pass into the function.
And no matter what I search for, every resources references to React Native, like as if nobody codes with Flutter since Firebase 9 has been released anymore (or I am the only dummy which is not able to resolve this by myself).
Can someone tell me where to get the firebaseConfig object from?
If I add a new app to my project, I only get the google-services.json, which does NOT include the firebaseConfig object I need to pass.
I understand your confusion now, let me explain. When the guy in the video talks about Firebase v9 he is talking about the SDK version which in the case of Javascript (which I suppose is his main topic in his channel) is currently 9.17.1 an the version 9 has been around since 2021 so it is not new. The different SDKs have their own versions for each platform so thinking it will be the same in every SDK is a mistake by itself. You can check the SDKS here. So there is no Firebase v9, there is a Firebase SDK for javascript version 9. They managed in that way in javascript and in flutter it is not the same. Being that the last update in the flutter SDK was literally yesterday I'm pretty sure they have their reasons to not implement the same functions in flutter since 2021.
Now, one of the thinks the guy talks in the video is deconstructing, which is something common in javascript. The way you do this in flutter is by using show.
So you would be doing this for example:
import 'package:cloud_firestore/cloud_firestore.dart' show FirebaseFirestore, QuerySnapshot; //Add everything you would be using
This way only the specific parts of the library will be imported and the amount of code the Dart VM has to load will be reduced.
As of the access to documents, it is still the same but you can easily create a helper class that contents your references to your collections and then just use that class to reduce the boilerplate code created by the firebase SDK.
You have to install the Firebase CLI and run firebase init.
You need to use the package firebase_core that will give you access to the class Firebase so you can use it to initialize your app Firebase.initializeApp() you can pass the default options for the current platform using Firebase.initilizeApp(options: DefaultFirebaseOptions.currentPlatform) usually your IDE will automatically import the corresponding package but in case it does not you would have to import 'firebase/firebase_options.dart';
An useful link to the documentation: Add Firebase to your Flutter App
I am new to Flutter and I feel like if I could see what the widgetTest is "rendering", as a debug method, things could be a bit easier. I don't fully understand at the moment the mechanics of the widgetTest, but I am wondering if it is possible to capture an actual output render in the middle of the widgetTest.
I am talking about widgetTest not integration test.
I think the package golden_toolkit might be what you are looking for. Instead of using widgetTest you will be using testGoldens. And you can even compare screenshots if you want to ensure non regression in your UI using the provided method screenMatchesGolden.
Add in your pubspec.yaml:
#This is a development environment dependency only
dev-dependencies:
golden_toolkit: ^0.9.0
Code Sample:
testGoldens('MyWidget test', (tester) async {
await tester.pumpWidget(MyWidget());
await screenMatchesGolden(tester, 'my_widget-example');
});
Then run the following command to generate or regenerate your reference images:
flutter test --update-goldens
You can check the documentation about testGoldens here.
I am trying to make an anime app using Flutter. For that I needed an REST API but I fortunately found a dart API. The problem is I cannot understand how to incorporate it in my app. This would really help me reduce the work load.
I am attaching the github link.
https://github.com/charafau/jikan-dart
If you are talking about how to include a package in your flutter Application, then you need to do the following:
add the package dependencies in the pubspec.yaml file
Get the package by running pub get
and then import the packages in your app using import
steps by step instructions also available here: https://dart.dev/guides/packages
also if you check the utilization of the API in the example code, you can find this example:
import 'package:jikan_dart/jikan_dart.dart';
main() async {
var jikanApi = JikanApi();
var top = await jikanApi.getTop(TopType.manga, page: 2);
print('result $top');
}
Is there any way to scan a credit card in flutter? i tried Card IO plug in and i tried using it but when i open the camera, it just shows me a box and when i focus on the card nothing happens.
Package used: https://pub.dartlang.org/packages/flutter_card_io
FlatButton(
onPressed: () async {
Map<String, dynamic> details = await FlutterCardIo.scanCard({
"requireExpiry": true,
"scanExpiry": true,
"requireCVV": false,
"requirePostalCode": false,
"restrictPostalCodeToNumericOnly": false,
"requireCardHolderName": false,
"scanInstructions": "Fit the card within the box",
});
print(details);
},
child: Text("Test"),
),
pubspec.yaml
dependencies:
flutter_card_io:
git:
url: git://github.com/procedurallygenerated/flutter_card_io.git
If there is any possible way that anyone knows of i would be grateful! I really need it for an important project i am doing.
A little late to the party I know, but I tried installing CardIO (the core one and the flutter one) anyway... Not only are they no longer maintained but they're not compatible :(
I got these errors on pub get.
The Android Gradle plugin supports only Kotlin Gradle plugin version 1.3.10 and higher. project ':core_card_io' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.71
core_card_io: ^0.0.2
Because myapp depends on flutter_card_io >=0.0.2 which requires SDK version >=1.8.0 <2.0.0, version solving failed.
flutter_card_io: ^0.0.3
So I found an alternative which does seem to do the job.
card_scanner 0.0.4
https://pub.dev/packages/card_scanner
https://pub.dev/documentation/card_scanner/latest/
https://github.com/nateshmbhat/card-scanner-flutter/blob/master/example/lib/main.dart
If you have another one to share, please do :)
Currently, there seems to be no other plugin publicly available for Flutter. However, the one you mentioned should work fine. Try compiling the example application that comes with the plugin and use multiple cards to test it. Keep in mind that Card.io only works with cards that have raised digits.
Query
I want to adding account with AccountManager in Flutter.
I have googled but I found in Android not in Flutter; I found flutter package:
https://pub.dev/packages/account_manager_plugin
this package get all account but never to add new account.
any body help me...
Currently, there is no available plugin that has all the features of Android’s AccountManager. You’ll either have to dive into its source to jumpstart and create your own plugin, wait for one to be available, or integrate your own Android-specific code.