flutter:如何按照 Apple 指南添加 Apple Pay 按钮

标签 flutter applepay

这是一个相当简单的问题,但我想知道如何将苹果支付按钮添加到您的 flutter 应用程序中。我是否需要按照苹果指南从头开始创建按钮,或者是否有可以使用的模板?我记得很快就有一个可用的对象。 谢谢

最佳答案

Flutter 没有像 Apple Pay 那样的任何按钮,也没有任何苹果图标。

所以,你可以在这里做两件事 ->

  1. 添加“Apple”自定义图标

  2. 添加“Apple”图像而不是图标(我想您知道这一点)

[如果您不知道如何添加图片,请告诉我]

然后你就可以创建这样的按钮...

  1. 访问this site ,搜索 apple 并选择“Apple Logo ”而不是“Apple Pay Logo ”,

    将文件名从“MyFlutterApp”更改为“Custom”并下载,

    解压文件,将 dart 文件添加到 lib 文件夹

    还有 Custom.ttf 文件( Assets 或字体文件夹或任何您想要的位置)

    并将其添加到 pubspec.yaml 的字体部分,如代码所示

这是代码:

//pubspec.yaml ->
fonts:
  - family: Custom
    fonts:
      - assets/Custom.ttf //path of Custom.ttf in you project

//Dart file where you will add Apple pay button
import'custom_icons.dart' as CustomIcon;//custom_icons.dart is one of the downloaded file

//THIS IS THE NORMAL WAY TO CREATE A BUTTON
RaisedButton(
  color: Colors.black,
  onPressed: (){ 
    //ADD THE FUNCTIONS OF THIS BUTTON HERE
  },
  child: Row(
    mainAxisAlignment: MainAxisAlignment.center,
    children: [
      Icon(CustomIcon.Custom.apple, color: Colors.white,),
      SizedBox(width: 8.0,),
      Text('Apple Pay', style: TextStyle(color: Colors.white),)
    ],
  ),
),

//USE THIS FOR CUSTOMISING YOUR BUTTON
Container(
  height: 30.0,
  width: double.infinity,
  decoration: BoxDecoration(
    borderRadius: BorderRadius.all(Radius.circular(8.0)),
    color: Colors.black
  ),
  child: GestureDetector(
    onTap: (){
      //ADD THE FUNCTIONS OF THIS BUTTON HERE
    },
    child: Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        Icon(CustomIcon.Custom.apple, color: Colors.white,),
        SizedBox(width: 8.0,),
        Text('Apple Pay', style: TextStyle(color: Colors.white),)
      ],
    ),
  ),
),

关于flutter:如何按照 Apple 指南添加 Apple Pay 按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62818232/

相关文章:

ios - 应用审核被拒绝 : Use 'Setup Apple Pay' Image Button

iphone - Swift Apple Pay 崩溃; PKPaymentAuthorizationViewController = 无

ios - 调试苹果支付消息支付请求无效: <private>

ios - 如何在真实设备上测试 Braintree + Apple Pay?

android - 如何打开设备设置表单 flutter 应用程序?

flutter - Flutter 中使用 auto_route 包实现同一页面的多个路径

Flutter:按下按钮时调用 setState() 两次

flutter - 如何在 FutureBuilder 完成获取项目之前加载其他静态元素

flutter - 如何在 flutter 中更改编辑日期格式(日期选择器)

ios - 测试 ApplePay SDK