因此,我在我的Flatter Web项目中实现了RazorPay支付网关。支付网关已成功实现。但我的问题是如何设置索引中定义的Javascript属性。html文件。
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
<meta name="description" content="A new Flutter project.">
<meta name="viewport" content="width=device-width">
<!-- iOS meta tags & icons -->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-title" content="razorpay_payment_with_flutter">
<link rel="apple-touch-icon" href="icons/Icon-192.png">
<!-- Favicon -->
<link rel="icon" type="image/png" href="favicon.png"/>
<title>razorpay_payment_with_flutter</title>
<link rel="manifest" href="manifest.json">
</head>
<body>
<script src="https://checkout.razorpay.com/v1/checkout.js"></script>
<script>
var options = {
"key": "my-api-key",
"amount": "10000", "currency": "INR",
"name": "Aniket Ambore",
"description": "Just a flutter web project",
"image": "https://i.ibb.co/BCwcPzN/Pngtree-flat-lay-home-office-concept-4341518.jpg",
"handler": function (response){
window.parent.postMessage("SUCCESS","*"); //2
alert(response.razorpay_payment_id);
alert(response.razorpay_order_id);
alert(response.razorpay_signature)
},
"prefill": {
"name": "",
"email": "",
"contact": ""
},
"notes": {
"address": "Autofy"
},
"theme": {
"color": "#DF0145"
},
"modal": {
"ondismiss": function(){
window.parent.postMessage("MODAL_CLOSED","*"); //3
}
}
};
var rzp1 = new Razorpay(options);
window.onload = function(e){ //1
rzp1.open();
e.preventDefault();
}
</script>
<!-- This script installs service_worker.js to provide PWA functionality to
application. For more information, see:
https://developers.google.com/web/fundamentals/primers/service-workers -->
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', function () {
navigator.serviceWorker.register('flutter_service_worker.js');
});
}
</script>
<script src="main.dart.js" type="application/javascript"></script>
</body>
</html>
上面的代码是我更新的索引的一小部分。html。我们如何从我的Flatter项目中设置var选项图的键。比如,如果我想更改金额的值,我如何将其从dart文件传递到索引。html。
我的颤振医生
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel master, 1.21.0-9.0.pre, on Microsoft Windows [Version 10.0.17134.1304], locale en-IN)
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[√] Chrome - develop for the web
[√] Android Studio (version 4.0)
[√] IntelliJ IDEA Community Edition (version 2019.2)
[√] Connected device (3 available)
! Doctor found issues in 1 category.
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
<meta name="description" content="A new Flutter project.">
<meta name="viewport" content="width=device-width">
<!-- iOS meta tags & icons -->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-title" content="razorpay_payment_with_flutter">
<link rel="apple-touch-icon" href="icons/Icon-192.png">
<!-- Favicon -->
<link rel="icon" type="image/png" href="favicon.png"/>
<title>razorpay_payment_with_flutter</title>
<link rel="manifest" href="manifest.json">
</head>
<body>
<script src="https://checkout.razorpay.com/v1/checkout.js"></script>
<script>
var options = {
"key": "my-api-key",
"amount": "10000", "currency": "INR",
"name": "Aniket Ambore",
"description": "Just a flutter web project",
"image": "https://i.ibb.co/BCwcPzN/Pngtree-flat-lay-home-office-concept-4341518.jpg",
"handler": function (response){
window.parent.postMessage("SUCCESS","*"); //2
alert(response.razorpay_payment_id);
alert(response.razorpay_order_id);
alert(response.razorpay_signature)
},
"prefill": {
"name": "",
"email": "",
"contact": ""
},
"notes": {
"address": "Autofy"
},
"theme": {
"color": "#DF0145"
},
"modal": {
"ondismiss": function(){
window.parent.postMessage("MODAL_CLOSED","*"); //3
}
}
};
var rzp1 = new Razorpay(options);
window.onload = function(e){ //1
rzp1.open();
e.preventDefault();
}
</script>
<!-- This script installs service_worker.js to provide PWA functionality to
application. For more information, see:
https://developers.google.com/web/fundamentals/primers/service-workers -->
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', function () {
navigator.serviceWorker.register('flutter_service_worker.js');
});
}
</script>
<script src="main.dart.js" type="application/javascript"></script>
</body>
</html>
razorpay_网。飞奔
import 'package:flutter/material.dart';
import 'dart:html';
import 'dart:ui' as ui;
import 'ui_fake.dart' if (dart.library.html) 'dart:ui' as ui;
class RazorPayWeb extends StatelessWidget {
@override
Widget build(BuildContext context) {
//register view factory
ui.platformViewRegistry.registerViewFactory("rzp-html",(int viewId) {
IFrameElement element=IFrameElement();
//Event Listener
window.onMessage.forEach((element) {
print('---------------------------Event Received in callback: ${element.data}');
if(element.data=='MODAL_CLOSED'){
Navigator.pop(context);
}else if(element.data=='SUCCESS'){
print('PAYMENT SUCCESSFULL!!!!!!!');
}
});
element.requestFullscreen();
//element.src='assets/html/payment.html';
element.style.border = 'none';
return element;
});
return Scaffold(
body: Builder(builder: (BuildContext context) {
return Container(
child: HtmlElementView(viewType: 'rzp-html'),
);
}));
}
}
你是假的。飞奔
import 'dart:ui' as ui;
// ignore: camel_case_types
class platformViewRegistry {
static registerViewFactory(String viewId, dynamic cb) {
ui.platformViewRegistry.registerViewFactory(viewId, cb);
}
}
主要的飞奔
import 'package:flutter/material.dart';
import 'package:razorpay_flutter/razorpay_flutter.dart';
import 'package:flutter/services.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:razorpay_payment_with_flutter/WebImplementation/razorpay_web.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
// This makes the visual density adapt to the platform that you run
// the app on. For desktop platforms, the controls will be smaller and
// closer together (more dense) than on mobile platforms.
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: RazorPayWeb(),
);
}
}
此外,该代码不处理razorpay_flatter
插件,因为它不适用于flatter_Web。
使用srddoc
属性,而不是iframelement
对象的src
属性来传递整个HTML内容。可以组合字符串插值来传递属性。
下面是一个例子:
//register view factory
ui.platformViewRegistry.registerViewFactory("rzp-html",(int viewId) {
IFrameElement element=IFrameElement();
//Event Listener
window.onMessage.forEach((element) {
print('---------------------------Event Received in callback: ${element.data}');
if(element.data=='MODAL_CLOSED'){
Navigator.pop(context);
}else if(element.data=='SUCCESS'){
print('PAYMENT SUCCESSFULL!!!!!!!');
}
});
element.requestFullscreen();
// ****************** change you need to make *************
element.srcdoc = '<html><p>Your entire HTML content with an ${attribute}</p></html>';
element.style.border = 'none';
return element;
});
我无法在尝试设置平台后修复颤振问题,问题如下所示: https://i.stack.imgur.com/uddfn.png
目前我正在尝试颤振网页,我需要在颤振主频道工作。但是,后来我需要继续我的其他项目。在他们身上,我正在研究颤振稳定通道。 但是,每当我使用命令“flutter channel stable”或“fluter channel master”切换我的flutter通道时,它每次都会重新下载sdk和其他工具。 目前,我已经下载了稳定的颤振sdk和稳定的dart sdk。 我已将它们移动到“FlutterS
我可以使用“startAfter”和“limit”进行分页,但它有错误。 例如,在Firestore DB中,我有7条记录: 当页面大小为5时,第一页就可以了,因为我使用了: 它给了我1-5项。 当它加载第二页时,我使用了: 问题是第二页结果只有item7,item6消失了。“开始”也有同样的问题。 真希望它有“抵消”功能,有人有解决办法吗?
我做了卡片,并设法用材料的颜色随意地给它们上色, 问题是,当我尝试使用十六进制颜色时,flutter给出了一个错误“颜色不是一个函数” 。下面的代码如果不在类中,也可以工作,但它只返回1个随机颜色。 完整的代码可以在这里找到https://gist.github.com/nevruzoglu/3db05f01706e5b2b4e75e24cded4a5b0