dcoupon_sdk_flutter_package 4.1.0 copy "dcoupon_sdk_flutter_package: ^4.1.0" to clipboard
dcoupon_sdk_flutter_package: ^4.1.0 copied to clipboard

outdated

dcoupon sdk flutter plugin project. Support flutter (Android/iOS) applications to integrate dcoupon web services for flutter projects.

example/lib/main.dart

import 'dart:async';
import 'dart:convert';
import 'package:dcoupon_sdk_flutter_package/dcoupon_sdk_flutter_package.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'app_config.dart';
import 'translations.dart';

import 'constants.dart';

void main({String env}) async {
  // load config
  final config = await AppConfig.forEnvironment(env);
  runApp(ExampleApp(config: config));
}

class ExampleApp extends StatelessWidget {
  // This widget is the root of your example application.
  final AppConfig config;

  ExampleApp({Key key, this.config}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        theme: ThemeData(
          brightness: Brightness.light,
          primarySwatch: Colors.blue,
        ),
        darkTheme: ThemeData(
          brightness: Brightness.dark,
          primarySwatch: Colors.blue,
        ),
        themeMode: ThemeMode.system,
        localizationsDelegates: [
          const TranslationsDelegate(),
          GlobalMaterialLocalizations.delegate,
          GlobalWidgetsLocalizations.delegate,
          GlobalCupertinoLocalizations.delegate,
        ],
        supportedLocales: [
          const Locale('en'),
          const Locale('es'),
        ],
        debugShowCheckedModeBanner: false,
        home: HomePage(config: config));
  }
}

class HomePage extends StatefulWidget {
  final AppConfig config;

  HomePage({Key key, this.config}) : super(key: key);

  @override
  _LoginPageState createState() => _LoginPageState();
}

class _LoginPageState extends State<HomePage> {
  _LoginPageState();

  Dcoupon dcoupon;
  bool _isLoading = false;
  bool layoutLoginVisible = true;
  var externalId, email, referralCode;
  var _formKey = GlobalKey<FormState>();
  String _responseMsg;
  int couponId = 0, start = 0, limit = 0, gmtTimeZoneOffset = 0;
  String inputAlias,
      inputGender,
      inputBirthdate,
      sortBy,
      promotionToken,
      latitude,
      longitude,
      source,
      transId,
      crmId,
      textSearch,
      zipcode,
      radius,
      orderBy,
      publisherToken = 'dcoupon-publisher',
      redemptionId,
      groupBy = 'MONTH',
      startDate,
      endDate,
      affiliateApiToken,
      cardNumber;
  List<String> promotionTokens,
      categoryIds,
      storeIds,
      retailerTokens,
      companyTokens;
  bool startVisible = false,
      limitVisible = false,
      couponIdVisible = false,
      gmtTimeZoneOffsetVisible = false,
      inputAliasVisible = false,
      inputGenderVisible = false,
      inputBirthdateVisible = false,
      sortByVisible = false,
      promotionTokensVisible = false,
      promotionTokenVisible = false,
      longitudeVisible = false,
      latitudeVisible = false,
      sourceVisible = false,
      transIdVisible = false,
      crmIdVisible = false,
      categoryIdsVisible = false,
      storeIdsVisible = false,
      textSearchVisible = false,
      zipcodeVisible = false,
      radiusVisible = false,
      retailerTokensVisible = false,
      companyTokensVisible = false,
      orderByVisible = false,
      publisherTokenVisible = false,
      redemptionIdVisible = false,
      groupByVisible = false,
      startDateVisible = false,
      endDateVisible = false,
      affiliateApiTokenVisible = false,
      cardNumberVisible = false;

  Future<String> loadString(String env) async {
    var contents = await rootBundle.loadString("lib/assets/config/$env.json");
    return contents;
  }

  @override
  initState() {
    super.initState();
    dcoupon = new Dcoupon(context: context);
    loadString(widget.config.environment).then((onValue) async {
      await dcoupon.loadConfig(onValue);
    });
    print(
      'Config: ' +
          "\nclientToken->" +
          widget.config.clientToken +
          "\nclientSecretKey->" +
          widget.config.clientSecretKey +
          "\nclientCountry->" +
          widget.config.clientCountry +
          "\nclientDomain->" +
          widget.config.clientDomain,
    );
    externalId = "flutterExternalId1";
    // email = "flutter-example-externalId1@email.com";
  }

  void _printMessage(String method, DcouponListener response) {
    JsonEncoder encoder = JsonEncoder.withIndent('  ');
    setState(() {
      _responseMsg = method + ' -> ' + response.code.toString();
      _isLoading = false;
      try {
        var prettyString = encoder.convert(jsonDecode(response.message));
        prettyString
            .split('\n')
            .forEach((element) => _responseMsg += '\n' + element);
      } catch (ex) {
        _responseMsg += '\n' + response.message;
      }
    });
  }

  Future<void> login() async {
    setState(() {
      _isLoading = true;
    });

    // do login
    dcoupon
        .login(
      externalId,
      email: email,
      referralCode: referralCode,
    )
        .then((response) async {
      if (response.code == 200) {
        setState(() {
          layoutLoginVisible = false;
          _isLoading = false;
        });
      }
    }).catchError((ex) {
      print("example.app.login.catchError: " + ex.toString());
    });
  }

  void logOut() async {
    setState(() {
      _isLoading = true;
    });
    await dcoupon.logOut();
    setState(() {
      layoutLoginVisible = true;
      _isLoading = false;
    });
  }

  @override
  void setState(fn) {
    super.setState(fn);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: Stack(
      children: [
        Center(
          child: _bodyForm(),
        ),
        Container(
          child: _isLoading
              ? Container(
                  color: Colors.grey[200].withAlpha(150),
                  height: MediaQuery.of(context).size.height,
                  child: Center(
                    child: CircularProgressIndicator(),
                  ),
                )
              : Container(),
        ),
      ],
    ));
  }

  String _currentMethod;

  void _changedDropDownCurrentMethod(String itemSelected) {
    setState(() {
      _currentMethod = itemSelected;
      startVisible = false;
      limitVisible = false;
      couponIdVisible = false;
      gmtTimeZoneOffsetVisible = false;
      inputAliasVisible = false;
      inputGenderVisible = false;
      inputBirthdateVisible = false;
      sortByVisible = false;
      promotionTokensVisible = false;
      promotionTokenVisible = false;
      longitudeVisible = false;
      latitudeVisible = false;
      sourceVisible = false;
      transIdVisible = false;
      crmIdVisible = false;
      categoryIdsVisible = false;
      storeIdsVisible = false;
      textSearchVisible = false;
      zipcodeVisible = false;
      radiusVisible = false;
      retailerTokensVisible = false;
      companyTokensVisible = false;
      orderByVisible = false;
      publisherTokenVisible = false;
      redemptionIdVisible = false;
      groupByVisible = false;
      startDateVisible = false;
      endDateVisible = false;
      affiliateApiTokenVisible = false;
      cardNumberVisible = false;

      switch (_currentMethod) {
        case Constants.GET_SESSION_TOKEN:
          break;
        case Constants.GET_USER_DATA:
          break;
        case Constants.UPDATE_USER_DATA:
          inputAliasVisible = true;
          inputGenderVisible = true;
          inputBirthdateVisible = true;
          break;
        case Constants.GET_COUPONS:
          startVisible = true;
          limitVisible = true;
          sortByVisible = true;
          companyTokensVisible = true;
          retailerTokensVisible = true;
          break;
        case Constants.GET_COUPON_DETAIL:
          couponIdVisible = true;
          break;
        case Constants.ACTIVATE_COUPON:
          couponIdVisible = true;
          break;
        case Constants.DEACTIVATE_COUPON:
          couponIdVisible = true;
          break;
        case Constants.CREATE_COUPONS:
          promotionTokensVisible = true;
          longitudeVisible = true;
          latitudeVisible = true;
          sourceVisible = true;
          transIdVisible = true;
          crmIdVisible = true;
          publisherTokenVisible = true;
          break;
        case Constants.GET_COUPONS_COMPANIES:
          break;
        case Constants.GET_COUPONS_RETAILERS:
          break;
        case Constants.GET_REDEMPTION_CODE:
          break;
        case Constants.GET_REDEMPTION_DETAIL:
          redemptionIdVisible = true;
          gmtTimeZoneOffsetVisible = true;
          break;
        case Constants.GET_REDEMPTION_SUMMARY:
          groupByVisible = true;
          startDateVisible = true;
          endDateVisible = true;
          gmtTimeZoneOffsetVisible = true;
          break;
        case Constants.GET_REDEMPTION_HISTORY:
          limitVisible = true;
          startVisible = true;
          startDateVisible = true;
          endDateVisible = true;
          gmtTimeZoneOffsetVisible = true;
          break;
        case Constants.GET_LOYALTY_AFFILIATES:
          break;
        case Constants.GET_LOYALTY_CARDS:
          break;
        case Constants.ADD_UPDATE_LOYALTY_CARD:
          affiliateApiTokenVisible = true;
          cardNumberVisible = true;
          break;
        case Constants.DELETE_LOYALTY_CARD:
          affiliateApiTokenVisible = true;
          cardNumberVisible = true;
          break;
        case Constants.GET_CATEGORIES:
          break;
        case Constants.GET_COMPANIES:
          startVisible = true;
          limitVisible = true;
          break;
        case Constants.GET_RETAILERS:
          startVisible = true;
          limitVisible = true;
          break;
        case Constants.GET_PROMOTIONS:
          startVisible = true;
          limitVisible = true;
          categoryIdsVisible = true;
          storeIdsVisible = true;
          longitudeVisible = true;
          latitudeVisible = true;
          textSearchVisible = true;
          retailerTokensVisible = true;
          companyTokensVisible = true;
          publisherTokenVisible = true;
          break;
        case Constants.GET_PROMOTION_DETAIL:
          promotionTokenVisible = true;
          publisherTokenVisible = true;
          break;
        case Constants.GET_STORES:
          startVisible = true;
          limitVisible = true;
          promotionTokenVisible = true;
          zipcodeVisible = true;
          radiusVisible = true;
          latitudeVisible = true;
          longitudeVisible = true;
          retailerTokensVisible = true;
          orderByVisible = true;
          publisherTokenVisible = true;
          break;
        default:
          break;
      }
    });
  }

  void _launchMethod() {
    setState(() {
      _isLoading = true;
      _responseMsg = "";
    });

    switch (_currentMethod) {
      case Constants.GET_SESSION_TOKEN:
        _printMessage(Constants.GET_SESSION_TOKEN, dcoupon.getSessionToken());
        break;
      case Constants.GET_USER_DATA:
        dcoupon.getUserData().then((response) {
          _printMessage(Constants.GET_USER_DATA, response);
        }).catchError((ex) {
          print("example.app.getUserData.catchError: " + ex.toString());
        });
        break;
      case Constants.UPDATE_USER_DATA:
        dcoupon
            .updateUserData(inputAlias, inputGender, inputBirthdate)
            .then((response) {
          _printMessage(Constants.UPDATE_USER_DATA, response);
        }).catchError((ex) {
          print("example.app.updateUserData.catchError: " + ex.toString());
        });
        break;
      case Constants.GET_COUPONS:
        dcoupon
            .getCoupons(
                offset: start,
                limit: limit,
                sortBy: sortBy,
                companyTokens: companyTokens,
                retailerTokens: retailerTokens)
            .then((response) {
          _printMessage(Constants.GET_COUPONS, response);
        }).catchError((ex) {
          print("example.app.getCoupons.catchError: " + ex.toString());
        });
        break;
      case Constants.GET_COUPON_DETAIL:
        dcoupon.getCouponDetail(couponId).then((response) {
          _printMessage(Constants.GET_COUPON_DETAIL, response);
        }).catchError((ex) {
          print("example.app.getCouponDetail.catchError: " + ex.toString());
        });
        break;
      case Constants.ACTIVATE_COUPON:
        dcoupon.activateCoupon(couponId).then((response) {
          _printMessage(Constants.ACTIVATE_COUPON, response);
        }).catchError((ex) {
          print("example.app.activateCoupon.catchError: " + ex.toString());
        });
        break;
      case Constants.DEACTIVATE_COUPON:
        dcoupon.deactivateCoupon(couponId).then((response) {
          _printMessage(Constants.DEACTIVATE_COUPON, response);
        }).catchError((ex) {
          print("example.app.deactivateCoupon.catchError: " + ex.toString());
        });
        break;
      case Constants.CREATE_COUPONS:
        dcoupon
            .createCoupons(
          promotionTokens,
          latitude: latitude,
          longitude: longitude,
          utmSource: source,
          transId: transId,
          crmId: crmId,
          publisherToken: publisherToken,
          saveMethod: 'example'
        )
            .then((response) {
          _printMessage(Constants.CREATE_COUPONS, response);
        }).catchError((ex) {
          print("example.app.createCoupons.catchError: " + ex.toString());
        });
        break;
      case Constants.GET_COUPONS_COMPANIES:
        dcoupon.getCouponsCompanies().then((response) {
          _printMessage(Constants.GET_COUPONS_COMPANIES, response);
        }).catchError((ex) {
          print("example.app.getCouponsCompanies.catchError: " + ex.toString());
        });
        break;
      case Constants.GET_COUPONS_RETAILERS:
        dcoupon.getCouponsRetailers().then((response) {
          _printMessage(Constants.GET_COUPONS_RETAILERS, response);
        }).catchError((ex) {
          print("example.app.getCouponsRetailers.catchError: " + ex.toString());
        });
        break;
      case Constants.GET_REDEMPTION_CODE:
        dcoupon.getRedemptionCode().then((response) {
          _printMessage(Constants.GET_REDEMPTION_CODE, response);
        }).catchError((ex) {
          print("example.app.getRedemptionCode.catchError: " + ex.toString());
        });
        break;
      case Constants.GET_REDEMPTION_HISTORY:
        dcoupon
            .getRedemptionHistory(
                limit: limit,
                startDate: startDate,
                endDate: endDate,
                gmtTimeZoneOffset: gmtTimeZoneOffset)
            .then((response) {
          _printMessage(Constants.GET_REDEMPTION_HISTORY, response);
        }).catchError((ex) {
          print(
              "example.app.getRedemptionHistory.catchError: " + ex.toString());
        });
        break;
      case Constants.GET_REDEMPTION_SUMMARY:
        dcoupon
            .getRedemptionSummary(groupBy,
                startDate: startDate,
                endDate: endDate,
                gmtTimeZoneOffset: gmtTimeZoneOffset)
            .then((response) {
          _printMessage(Constants.GET_REDEMPTION_SUMMARY, response);
        }).catchError((ex) {
          print(
              "example.app.getRedemptionSummary.catchError: " + ex.toString());
        });
        break;
      case Constants.GET_REDEMPTION_DETAIL:
        dcoupon
            .getRedemptionDetail(redemptionId,
                gmtTimeZoneOffset: gmtTimeZoneOffset)
            .then((response) {
          _printMessage(Constants.GET_REDEMPTION_DETAIL, response);
        }).catchError((ex) {
          print("example.app.getRedemptionDetail.catchError: " + ex.toString());
        });
        break;
      case Constants.GET_LOYALTY_AFFILIATES:
        dcoupon.getLoyaltyAffiliates().then((response) {
          _printMessage(Constants.GET_LOYALTY_AFFILIATES, response);
        }).catchError((ex) {
          print(
              "example.app.getLoyaltyAffiliates.catchError: " + ex.toString());
        });
        break;
      case Constants.GET_LOYALTY_CARDS:
        dcoupon.getLoyaltyCards().then((response) {
          _printMessage(Constants.GET_LOYALTY_CARDS, response);
        }).catchError((ex) {
          print("example.app.getLoyaltyCards.catchError: " + ex.toString());
        });
        break;
      case Constants.ADD_UPDATE_LOYALTY_CARD:
        dcoupon
            .addUpdateLoyaltyCard(affiliateApiToken, cardNumber)
            .then((response) {
          _printMessage(Constants.ADD_UPDATE_LOYALTY_CARD, response);
        }).catchError((ex) {
          print(
              "example.app.addUpdateLoyaltyCard.catchError: " + ex.toString());
        });
        break;
      case Constants.DELETE_LOYALTY_CARD:
        dcoupon
            .deleteLoyaltyCard(affiliateApiToken, cardNumber)
            .then((response) {
          _printMessage(Constants.DELETE_LOYALTY_CARD, response);
        }).catchError((ex) {
          print("example.app.deleteLoyaltyCard.catchError: " + ex.toString());
        });
        break;
      case Constants.GET_CATEGORIES:
        dcoupon.getCategories(publisherToken: publisherToken).then((response) {
          _printMessage(Constants.GET_CATEGORIES, response);
        }).catchError((ex) {
          print("example.app.getFilters.catchError: " + ex.toString());
        });
        break;
      case Constants.GET_COMPANIES:
        dcoupon
            .getCompanies(
                start: start, limit: limit, publisherToken: publisherToken)
            .then((response) {
          _printMessage(Constants.GET_COMPANIES, response);
        }).catchError((ex) {
          print("example.app.getFilters.catchError: " + ex.toString());
        });
        break;
      case Constants.GET_RETAILERS:
        dcoupon
            .getRetailers(
                start: start, limit: limit, publisherToken: publisherToken)
            .then((response) {
          _printMessage(Constants.GET_RETAILERS, response);
        }).catchError((ex) {
          print("example.app.getFilters.catchError: " + ex.toString());
        });
        break;
      case Constants.GET_PROMOTIONS:
        dcoupon
            .getPromotions(
                start: start,
                limit: limit,
                longitude: longitude,
                latitude: latitude,
                zipcode: zipcode,
                retailerTokens: retailerTokens,
                orderBy: orderBy,
                radius: radius,
                textSearch: textSearch,
                companyTokens: companyTokens,
                storeIds: storeIds,
                categoryIds: categoryIds,
                publisherToken: publisherToken)
            .then((response) {
          _printMessage(Constants.GET_PROMOTIONS, response);
        }).catchError((ex) {
          print("example.app.getPromotions.catchError: " + ex.toString());
        });
        break;
      case Constants.GET_PROMOTION_DETAIL:
        dcoupon
            .getPromotionDetail(promotionToken, publisherToken: publisherToken)
            .then((response) {
          _printMessage(Constants.GET_PROMOTION_DETAIL, response);
        }).catchError((ex) {
          print("dcoupon.getPromotionDetail.catchError: " + ex.toString());
        });
        break;
      case Constants.GET_STORES:
        dcoupon
            .getStores(promotionToken,
                start: start,
                limit: limit,
                retailerTokens: retailerTokens,
                zipcode: zipcode,
                latitude: latitude,
                longitude: longitude,
                radius: radius,
                publisherToken: publisherToken)
            .then((response) {
          _printMessage(Constants.GET_STORES, response);
        }).catchError((ex) {
          print("example.app.getStores.catchError: " + ex.toString());
        });
        break;
      default:
        break;
    }
  }

  Widget _bodyForm() {
    return SingleChildScrollView(
      scrollDirection: Axis.vertical,
      padding: EdgeInsets.all(8.0),
      child: Column(
        children: <Widget>[
          Image(
            fit: BoxFit.scaleDown,
            image: AssetImage('lib/assets/images/example_dcoupon_logo.png'),
          ),
          SizedBox(
            height: 32,
          ),
          Form(
              key: _formKey,
              child: Container(
                  child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: <Widget>[
                  Visibility(
                    visible: layoutLoginVisible,
                    child: Column(
                      children: <Widget>[
                        Row(
                          crossAxisAlignment: CrossAxisAlignment.center,
                          mainAxisAlignment: MainAxisAlignment.center,
                          children: <Widget>[
                            Expanded(
                              child: Container(
                                child: Column(
                                  children: <Widget>[
                                    TextFormField(
                                      initialValue: externalId,
                                      decoration: InputDecoration(
                                          labelText: Translations.of(context)
                                              .text('example_externalId')),
                                      onChanged: (text) {
                                        externalId = text;
                                      },
                                      validator: (value) {
                                        if (value.isEmpty) {
                                          return (Translations.of(context).text(
                                                  'example_missed_parameter') +
                                              " " +
                                              Translations.of(context)
                                                  .text('example_externalId'));
                                        }
                                        return null;
                                      },
                                    ),
                                    TextFormField(
                                      decoration: InputDecoration(
                                        labelText: Translations.of(context)
                                            .text('example_email'),
                                      ),
                                      onChanged: (text) {
                                        email = text;
                                      },
                                      validator: (value) {
                                        if (value.isEmpty) {
                                          return (Translations.of(context).text(
                                                  'example_missed_parameter') +
                                              " " +
                                              Translations.of(context)
                                                  .text('example_email'));
                                        }
                                        return null;
                                      },
                                    ),
                                    TextFormField(
                                      decoration: InputDecoration(
                                        labelText: Translations.of(context)
                                            .text('example_referralCode'),
                                      ),
                                      onChanged: (text) {
                                        referralCode = text;
                                      },
                                      validator: (value) {
                                        if (value.isEmpty) {
                                          return (Translations.of(context).text(
                                                  'example_missed_parameter') +
                                              " " +
                                              Translations.of(context).text(
                                                  'example_referralCode'));
                                        }
                                        return null;
                                      },
                                    ),
                                  ],
                                ),
                              ),
                            )
                          ],
                        ),
                        Row(
                          crossAxisAlignment: CrossAxisAlignment.center,
                          mainAxisAlignment: MainAxisAlignment.center,
                          children: <Widget>[
                            ElevatedButton(
                              onPressed: login,
                              style: ElevatedButton.styleFrom(
                                primary: Colors.blue,
                              ),
                              child: Row(
                                children: <Widget>[
                                  Text(Translations.of(context)
                                      .text('example_button_login'))
                                ],
                              ),
                            )
                          ],
                        )
                      ],
                    ),
                  ),
                  Visibility(
                    visible: !layoutLoginVisible,
                    child: Container(
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.center,
                        children: <Widget>[
                          RichText(
                            text: TextSpan(
                                text: Translations.of(context)
                                    .text('example_text_welcome'),
                                style: TextStyle(
                                    fontStyle: FontStyle.normal,
                                    fontSize: 20,
                                    color: Colors.black)),
                            overflow: TextOverflow.fade,
                          ),
                          Row(
                            mainAxisAlignment: MainAxisAlignment.center,
                            children: <Widget>[
                              ElevatedButton(
                                onPressed: logOut,
                                style: ElevatedButton.styleFrom(
                                  primary: Colors.blue,
                                ),
                                child: Row(
                                  children: <Widget>[
                                    Text(Translations.of(context)
                                        .text('example_button_logout'))
                                  ],
                                ),
                              )
                            ],
                          ),
                        ],
                      ),
                    ),
                  ),
                  Visibility(
                    visible: !layoutLoginVisible,
                    child: Row(
                      crossAxisAlignment: CrossAxisAlignment.center,
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: <Widget>[
                        Expanded(
                          child: Container(
                            child: Column(
                              children: <Widget>[
                                Visibility(
                                  visible: startVisible,
                                  child: TextFormField(
                                    initialValue: start.toString(),
                                    decoration:
                                        InputDecoration(labelText: 'start'),
                                    onChanged: (text) {
                                      start = int.parse(text);
                                    },
                                    keyboardType: TextInputType.number,
                                  ),
                                ),
                                Visibility(
                                  visible: limitVisible,
                                  child: TextFormField(
                                    initialValue: limit.toString(),
                                    decoration:
                                        InputDecoration(labelText: 'limit'),
                                    onChanged: (text) {
                                      limit = int.parse(text);
                                    },
                                    keyboardType: TextInputType.number,
                                  ),
                                ),
                                Visibility(
                                  visible: couponIdVisible,
                                  child: TextFormField(
                                    initialValue: couponId.toString(),
                                    decoration:
                                        InputDecoration(labelText: 'couponId'),
                                    onChanged: (text) {
                                      couponId = int.parse(text);
                                    },
                                  ),
                                ),
                                Visibility(
                                  visible: gmtTimeZoneOffsetVisible,
                                  child: TextFormField(
                                    initialValue: gmtTimeZoneOffset.toString(),
                                    decoration: InputDecoration(
                                        labelText: 'gmtTimeZoneOffset'),
                                    onChanged: (text) {
                                      gmtTimeZoneOffset = int.parse(text);
                                    },
                                  ),
                                ),
                                Visibility(
                                  visible: inputAliasVisible,
                                  child: TextFormField(
                                    initialValue: inputAlias,
                                    decoration: InputDecoration(
                                      labelText: 'alias',
                                    ),
                                    onChanged: (text) {
                                      inputAlias = text;
                                    },
                                  ),
                                ),
                                Visibility(
                                  visible: inputGenderVisible,
                                  child: TextFormField(
                                    initialValue: inputGender,
                                    decoration: InputDecoration(
                                      labelText: 'gender',
                                    ),
                                    onChanged: (text) {
                                      inputGender = text;
                                    },
                                  ),
                                ),
                                Visibility(
                                  visible: inputBirthdateVisible,
                                  child: TextFormField(
                                    initialValue: inputBirthdate,
                                    decoration: InputDecoration(
                                      labelText: 'birthdate',
                                    ),
                                    onChanged: (text) {
                                      inputBirthdate = text;
                                    },
                                  ),
                                ),
                                Visibility(
                                  visible: sortByVisible,
                                  child: TextFormField(
                                    initialValue: sortBy,
                                    decoration:
                                        InputDecoration(labelText: 'sortBy'),
                                    onChanged: (text) {
                                      sortBy = text;
                                    },
                                  ),
                                ),
                                Visibility(
                                  visible: promotionTokensVisible,
                                  child: TextFormField(
                                    initialValue: promotionTokens == null
                                        ? ''
                                        : promotionTokens.join(","),
                                    decoration: InputDecoration(
                                        labelText: 'promotionTokens'),
                                    onChanged: (text) {
                                      promotionTokens = text.split(",");
                                    },
                                  ),
                                ),
                                Visibility(
                                  visible: promotionTokenVisible,
                                  child: TextFormField(
                                    initialValue: promotionToken,
                                    decoration: InputDecoration(
                                        labelText: 'promotionToken'),
                                    onChanged: (text) {
                                      promotionToken = text;
                                    },
                                  ),
                                ),
                                Visibility(
                                  visible: longitudeVisible,
                                  child: TextFormField(
                                    initialValue: longitude,
                                    decoration:
                                        InputDecoration(labelText: 'longitude'),
                                    onChanged: (text) {
                                      longitude = text;
                                    },
                                  ),
                                ),
                                Visibility(
                                  visible: latitudeVisible,
                                  child: TextFormField(
                                    initialValue: latitude,
                                    decoration:
                                        InputDecoration(labelText: 'latitude'),
                                    onChanged: (text) {
                                      latitude = text;
                                    },
                                  ),
                                ),
                                Visibility(
                                  visible: sourceVisible,
                                  child: TextFormField(
                                    initialValue: source,
                                    decoration:
                                        InputDecoration(labelText: 'source'),
                                    onChanged: (text) {
                                      source = text;
                                    },
                                  ),
                                ),
                                Visibility(
                                  visible: transIdVisible,
                                  child: TextFormField(
                                    initialValue: transId,
                                    decoration:
                                        InputDecoration(labelText: 'transId'),
                                    onChanged: (text) {
                                      transId = text;
                                    },
                                  ),
                                ),
                                Visibility(
                                  visible: crmIdVisible,
                                  child: TextFormField(
                                    initialValue: crmId,
                                    decoration:
                                        InputDecoration(labelText: 'crmId'),
                                    onChanged: (text) {
                                      crmId = text;
                                    },
                                  ),
                                ),
                                Visibility(
                                  visible: categoryIdsVisible,
                                  child: TextFormField(
                                    initialValue: categoryIds == null
                                        ? '0'
                                        : categoryIds.join(","),
                                    decoration: InputDecoration(
                                        labelText: 'categoryIds'),
                                    onChanged: (text) {
                                      categoryIds = text.split(",");
                                    },
                                  ),
                                ),
                                Visibility(
                                  visible: storeIdsVisible,
                                  child: TextFormField(
                                    initialValue: storeIds == null
                                        ? ''
                                        : storeIds.join(","),
                                    decoration:
                                        InputDecoration(labelText: 'storeIds'),
                                    onChanged: (text) {
                                      storeIds = text.split(",");
                                    },
                                  ),
                                ),
                                Visibility(
                                  visible: textSearchVisible,
                                  child: TextFormField(
                                    initialValue: textSearch,
                                    decoration: InputDecoration(
                                        labelText: 'textSearch'),
                                    onChanged: (text) {
                                      textSearch = text;
                                    },
                                  ),
                                ),
                                Visibility(
                                  visible: zipcodeVisible,
                                  child: TextFormField(
                                    initialValue: zipcode,
                                    decoration:
                                        InputDecoration(labelText: 'zipcode'),
                                    onChanged: (text) {
                                      zipcode = text;
                                    },
                                  ),
                                ),
                                Visibility(
                                  visible: radiusVisible,
                                  child: TextFormField(
                                    initialValue: radius,
                                    decoration:
                                        InputDecoration(labelText: 'radius'),
                                    onChanged: (text) {
                                      radius = text;
                                    },
                                  ),
                                ),
                                Visibility(
                                  visible: companyTokensVisible,
                                  child: TextFormField(
                                    initialValue: companyTokens == null
                                        ? ''
                                        : companyTokens.join(","),
                                    decoration: InputDecoration(
                                        labelText: 'companyTokens'),
                                    onChanged: (text) {
                                      companyTokens = text.split(",");
                                    },
                                  ),
                                ),
                                Visibility(
                                  visible: retailerTokensVisible,
                                  child: TextFormField(
                                    initialValue: retailerTokens == null
                                        ? ''
                                        : retailerTokens.join(","),
                                    decoration: InputDecoration(
                                        labelText: 'retailerTokens'),
                                    onChanged: (text) {
                                      retailerTokens = text.split(",");
                                    },
                                  ),
                                ),
                                Visibility(
                                  visible: orderByVisible,
                                  child: TextFormField(
                                    initialValue: orderBy,
                                    decoration:
                                        InputDecoration(labelText: 'orderBy'),
                                    onChanged: (text) {
                                      orderBy = text;
                                    },
                                  ),
                                ),
                                Visibility(
                                  visible: publisherTokenVisible,
                                  child: TextFormField(
                                    initialValue: publisherToken,
                                    decoration: InputDecoration(
                                        labelText: 'publisherToken'),
                                    onChanged: (text) {
                                      publisherToken = text;
                                    },
                                  ),
                                ),
                                Visibility(
                                  visible: redemptionIdVisible,
                                  child: TextFormField(
                                    initialValue: redemptionId,
                                    decoration: InputDecoration(
                                        labelText: 'redemptionId'),
                                    onChanged: (text) {
                                      redemptionId = text;
                                    },
                                  ),
                                ),
                                Visibility(
                                  visible: groupByVisible,
                                  child: TextFormField(
                                    initialValue: groupBy,
                                    decoration:
                                        InputDecoration(labelText: 'groupBy'),
                                    onChanged: (text) {
                                      groupBy = text;
                                    },
                                  ),
                                ),
                                Visibility(
                                  visible: startDateVisible,
                                  child: TextFormField(
                                    initialValue: startDate,
                                    decoration:
                                        InputDecoration(labelText: 'startDate'),
                                    onChanged: (text) {
                                      startDate = text;
                                    },
                                  ),
                                ),
                                Visibility(
                                  visible: endDateVisible,
                                  child: TextFormField(
                                    initialValue: endDate,
                                    decoration:
                                        InputDecoration(labelText: 'endDate'),
                                    onChanged: (text) {
                                      endDate = text;
                                    },
                                  ),
                                ),
                                Visibility(
                                  visible: affiliateApiTokenVisible,
                                  child: TextFormField(
                                    initialValue: affiliateApiToken,
                                    decoration: InputDecoration(
                                        labelText: 'affiliateApiToken'),
                                    onChanged: (text) {
                                      affiliateApiToken = text;
                                    },
                                  ),
                                ),
                                Visibility(
                                  visible: cardNumberVisible,
                                  child: TextFormField(
                                    initialValue: cardNumber,
                                    decoration: InputDecoration(
                                        labelText: 'cardNumber'),
                                    onChanged: (text) {
                                      cardNumber = text;
                                    },
                                  ),
                                ),
                              ],
                            ),
                          ),
                        )
                      ],
                    ),
                  ),
                  Visibility(
                    visible: !layoutLoginVisible,
                    child: Row(
                      crossAxisAlignment: CrossAxisAlignment.center,
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: <Widget>[
                        Expanded(
                          child: Container(
                            child: Column(
                              children: <Widget>[
                                new DropdownButton(
                                  isExpanded: true,
                                  hint: new Text(Translations.of(context)
                                      .text('example_select_hint')),
                                  value: _currentMethod,
                                  items: [
                                    DropdownMenuItem(
                                      value: Constants.GET_SESSION_TOKEN,
                                      child: Text(Constants.GET_SESSION_TOKEN),
                                    ),
                                    DropdownMenuItem(
                                      value: Constants.GET_USER_DATA,
                                      child: Text(Constants.GET_USER_DATA),
                                    ),
                                    DropdownMenuItem(
                                      value: Constants.UPDATE_USER_DATA,
                                      child: Text(Constants.UPDATE_USER_DATA),
                                    ),
                                    DropdownMenuItem(
                                      value: Constants.GET_COUPONS,
                                      child: Text(Constants.GET_COUPONS),
                                    ),
                                    DropdownMenuItem(
                                      value: Constants.GET_COUPON_DETAIL,
                                      child: Text(Constants.GET_COUPON_DETAIL),
                                    ),
                                    DropdownMenuItem(
                                      value: Constants.ACTIVATE_COUPON,
                                      child: Text(Constants.ACTIVATE_COUPON),
                                    ),
                                    DropdownMenuItem(
                                      value: Constants.DEACTIVATE_COUPON,
                                      child: Text(Constants.DEACTIVATE_COUPON),
                                    ),
                                    DropdownMenuItem(
                                      value: Constants.CREATE_COUPONS,
                                      child: Text(Constants.CREATE_COUPONS),
                                    ),
                                    DropdownMenuItem(
                                      value: Constants.GET_COUPONS_COMPANIES,
                                      child:
                                          Text(Constants.GET_COUPONS_COMPANIES),
                                    ),
                                    DropdownMenuItem(
                                      value: Constants.GET_COUPONS_RETAILERS,
                                      child:
                                          Text(Constants.GET_COUPONS_RETAILERS),
                                    ),
                                    DropdownMenuItem(
                                      value: Constants.GET_REDEMPTION_CODE,
                                      child:
                                          Text(Constants.GET_REDEMPTION_CODE),
                                    ),
                                    DropdownMenuItem(
                                      value: Constants.GET_REDEMPTION_HISTORY,
                                      child: Text(
                                          Constants.GET_REDEMPTION_HISTORY),
                                    ),
                                    DropdownMenuItem(
                                      value: Constants.GET_REDEMPTION_SUMMARY,
                                      child: Text(
                                          Constants.GET_REDEMPTION_SUMMARY),
                                    ),
                                    DropdownMenuItem(
                                      value: Constants.GET_REDEMPTION_DETAIL,
                                      child:
                                          Text(Constants.GET_REDEMPTION_DETAIL),
                                    ),
                                    DropdownMenuItem(
                                      value: Constants.GET_LOYALTY_AFFILIATES,
                                      child: Text(
                                          Constants.GET_LOYALTY_AFFILIATES),
                                    ),
                                    DropdownMenuItem(
                                      value: Constants.GET_LOYALTY_CARDS,
                                      child: Text(Constants.GET_LOYALTY_CARDS),
                                    ),
                                    DropdownMenuItem(
                                      value: Constants.ADD_UPDATE_LOYALTY_CARD,
                                      child: Text(
                                          Constants.ADD_UPDATE_LOYALTY_CARD),
                                    ),
                                    DropdownMenuItem(
                                      value: Constants.DELETE_LOYALTY_CARD,
                                      child:
                                          Text(Constants.DELETE_LOYALTY_CARD),
                                    ),
                                    DropdownMenuItem(
                                      value: Constants.GET_CATEGORIES,
                                      child: Text(Constants.GET_CATEGORIES),
                                    ),
                                    DropdownMenuItem(
                                      value: Constants.GET_COMPANIES,
                                      child: Text(Constants.GET_COMPANIES),
                                    ),
                                    DropdownMenuItem(
                                      value: Constants.GET_RETAILERS,
                                      child: Text(Constants.GET_RETAILERS),
                                    ),
                                    DropdownMenuItem(
                                      value: Constants.GET_PROMOTIONS,
                                      child: Text(Constants.GET_PROMOTIONS),
                                    ),
                                    DropdownMenuItem(
                                      value: Constants.GET_PROMOTION_DETAIL,
                                      child:
                                          Text(Constants.GET_PROMOTION_DETAIL),
                                    ),
                                    DropdownMenuItem(
                                      value: Constants.GET_STORES,
                                      child: Text(Constants.GET_STORES),
                                    ),
                                  ],
                                  onChanged: _changedDropDownCurrentMethod,
                                ),
                                ElevatedButton(
                                  onPressed: _launchMethod,
                                  style: ElevatedButton.styleFrom(
                                    primary: Colors.blue,
                                  ),
                                  child: Row(
                                    children: <Widget>[
                                      Text(Translations.of(context)
                                          .text('example_button_launch_method'))
                                    ],
                                  ),
                                )
                              ],
                            ),
                          ),
                        )
                      ],
                    ),
                  ),
                  Row(
                    children: <Widget>[
                      Expanded(
                        child: Container(
                          child: Column(
                            children: <Widget>[],
                          ),
                        ),
                      )
                    ],
                  ),
                  Row(
                    children: <Widget>[
                      Expanded(
                        child: Container(
                          child: Column(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            mainAxisAlignment: MainAxisAlignment.center,
                            children: <Widget>[
                              SelectableText.rich(TextSpan(
                                  text: _responseMsg,
                                  style: TextStyle(
                                      color: Colors.black, fontSize: 14))),
                            ],
                          ),
                        ),
                      )
                    ],
                  )
                ],
              ))),
        ],
      ),
    );
  }
}
2
likes
0
points
150
downloads

Publisher

verified publisherdcoupon.com

Weekly Downloads

dcoupon sdk flutter plugin project. Support flutter (Android/iOS) applications to integrate dcoupon web services for flutter projects.

Homepage

License

unknown (license)

Dependencies

collection, crypto, cupertino_icons, dartz, dio, equatable, flutter, flutter_html, flutter_localizations, get_it, html_unescape, intl, ntp

More

Packages that depend on dcoupon_sdk_flutter_package