danasdk 0.0.1 copy "danasdk: ^0.0.1" to clipboard
danasdk: ^0.0.1 copied to clipboard

outdated

Dana SDK built for Flutter.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:danasdk/danasdk.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final _danasdkPlugin = Danasdk();

  String phone = "";
  String companyKey = "";
  String orgLogo = "";

  List companies = [
    {
      "name": "Dana",
      "companyKey":
          "fo6Gs5d8pEnGVdbTKISO8JJFdAZMYUa5tjoeuEgEYaSTqgu0YPKK5KvVWHHoLwsG",
      "logo":
          "https://dana.money/storage/logo/47nmIK76OF8UPdx07KOgIZxJekuUNfEMHsungk25.png",
      "number": "01677079251",
    },
    {
      "name": "OkWallet",
      "companyKey":
          "NFnetbIkvMBR7vetObJbMnvXDcF5fKJBheDXATJS51HgDhdoQFUk8ZFWw4zfUl46",
      "logo":
          "https://test.dana.money/cp/contents/images/50fa9e3a313d58b225c62437095e19f2.jpeg",
      "number": "01912336306",
    },
  ];

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    final formKey = GlobalKey<FormState>();
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text("Flutter Wrapper for Dana SDK"),
        ),
        body: Padding(
          padding: const EdgeInsets.all(16.0),
          child: Form(
            key: formKey,
            child: Column(
              mainAxisSize: MainAxisSize.max,
              children: [
                DropdownButtonFormField(
                  decoration: const InputDecoration(
                    prefixIcon: Icon(Icons.settings),
                    hintText: 'Select Company',
                    filled: true,
                    fillColor: Colors.white,
                    errorStyle: TextStyle(color: Colors.red),
                  ),
                  items: companies.map((map) {
                    return DropdownMenuItem(
                      value: map['companyKey'],
                      child: Text(map['name']),
                    );
                  }).toList(),
                  onChanged: (value) {
                    for (Map<String, String> company in companies) {
                      if (company['companyKey'] == value) {
                        phone = company['number']!;
                        orgLogo = company['logo']!;
                        companyKey = company['companyKey']!;
                        setState(() {});
                      }
                    }
                  },
                ),
                const SizedBox(height: 20),
                orgLogo != ""
                    ? Image.network(
                        orgLogo,
                        height: 100,
                        width: 160,
                      )
                    : Container(),
                const SizedBox(height: 20),
                TextFormField(
                  initialValue: phone,
                  onChanged: (value) {},
                  validator: (value) {
                    if (value == null || value.isEmpty) {
                      return 'Please enter some text';
                    }
                    return null;
                  },
                  decoration: const InputDecoration(
                      border: OutlineInputBorder(),
                      hintText: "Enter phone number"),
                ),
                const SizedBox(height: 20),
                TextFormField(
                  initialValue: companyKey,
                  onChanged: (value) {},
                  validator: (value) {
                    if (value == null || value.isEmpty) {
                      return 'Please enter some text';
                    }
                    return null;
                  },
                  decoration: const InputDecoration(
                      border: OutlineInputBorder(),
                      hintText: "Enter Company Key"),
                ),
                const SizedBox(height: 20),
                ElevatedButton(
                  onPressed: () {
                    if (formKey.currentState!.validate()) {
                      _danasdkPlugin.runSdk(phone, companyKey, orgLogo);
                    }
                  },
                  child: const Text("Run SDK"),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
1
likes
0
points
21
downloads

Publisher

verified publisherdana.money

Weekly Downloads

Dana SDK built for Flutter.

Homepage

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on danasdk