Error: Cannot run with sound null safety, because the following dependencies don't support null safety:
For solutions, see https://dart.dev/go/unsound-null-safety
Unhandled exception: Bad state: Unsupported Null Safety mode NonNullableByDefaultCompiledMode.Invalid, in null.
version: 1.0.0+1
configurations:
- name: "Flutter"
request: "launch"
type: "dart"
program: "lib/fill_detail.dart"
args: ["--sound-null-safety"]
environment:
sdk: '>=2.19.5 <3.0.0'
dependencies:
flutter:
sdk: flutter
payu_checkoutpro_flutter: ^1.0.2
payu_money_flutter: ^0.0.3
@override
void initState() {
super.initState();
fetchCountries();
fetchPlans();
setupPayment();
}
String txnToken = "your_transaction_token";
String orderId = "your_order_id";
double amount1 = 10.0;
// Function for setting up the payment details
PayuMoneyFlutter payuMoneyFlutter = PayuMoneyFlutter();
setupPayment() async {
bool response = await payuMoneyFlutter.setupPaymentKeys(
merchantKey: "nxpvv9VZ",
merchantID: "3oFxUMtWG2",
isProduction: true,
activityTitle: "Payumoney",
disableExitConfirmation: false,
);
print("response --> $response");
}
void handlePaymentResponse(Map<String, dynamic> paymentResponse) {
String responseCode = paymentResponse['responseCode'];
String status = paymentResponse['status'];
String message = paymentResponse['message'];
String transactionId = paymentResponse['transactionId'];
if (responseCode == "01" && status == "success") {
// Payment successful
print("Payment successful. Transaction ID: $transactionId");
} else if (responseCode == "141" && status == "userCancelled") {
// Payment cancelled by user
print("Payment cancelled by user");
} else {
// Payment failed
print("Payment failed. Response Code: $responseCode. Message: $message");
}
}
@override
void dispose() {
super.dispose();
setupPayment();
}
I want permanently solve null sound safety error in this code.
You cannot solve this problem, because it's not your problem. The package you want to use is a pre-release project that wasn't updated for 2 years now.
Using a pre-release project that isn't maintained anymore for payment is... risky at best.
You can either use an old version of Flutter that will accept packages that old. Or you can take that package, fork it and update it to null-safety yourself. Of you could use a payment provider, that is actually actively maintaining a package for Flutter.
They seem to have an official package, so that might be your way forward.