dcoupon_sdk_flutter_package 1.0.5 dcoupon_sdk_flutter_package: ^1.0.5 copied to clipboard
dcoupon sdk flutter plugin project. Support flutter (Android/iOS) applications to integrate dcoupon web services for flutter projects.
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(
primarySwatch: Colors.blue,
),
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 layoutLoginVisible = true;
var email, externalId, alias, gender, birthdate;
var _formKey = GlobalKey<FormState>();
String _responseMsg;
String couponId = '0',
start = '0',
limit = '0',
sortBy,
promotionToken,
latitude,
longitude,
source,
transId,
crmId,
textSearch,
zipcode,
radius,
orderBy,
redemptionId,
gtmTimeZoneOffset = '0',
groupBy = 'YEAR',
startDate,
endDate,
affiliateApiToken,
cardNumber,
publisherName = 'dcoupon-publisher';
List<String> promotionTokens,
categoryIds,
storeIds,
retailerTokens,
companyTokens;
bool startVisible = false,
limitVisible = false,
sortByVisible = false,
couponIdVisible = 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,
redemptionIdVisible = false,
gtmTimeZoneOffsetVisible = 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 +
"\nclientPublishers->" +
widget.config.clientPublishers.toString());
email = "flutter-example@email.com";
externalId = "flutter-example-externalId";
alias = "flutter-example-alias";
gender = "MALE";
birthdate = "1990-12-25";
}
void _printMessage(String method, DcouponListener response) {
JsonEncoder encoder = JsonEncoder.withIndent(' ');
setState(() {
_responseMsg = method + ' -> ' + response.code.toString();
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 {
// do login
dcoupon
.logIn(
email,
externalId,
alias: alias,
gender: gender,
birthdate: birthdate,
)
.then((response) async {
_printMessage('login', response);
final isLoggedIn = await dcoupon.isLoggedIn();
print("example.app.isLogged->" + isLoggedIn.toString());
if (isLoggedIn) {
layoutLoginVisible = false;
}
}).catchError((ex) {
print("example.app.login.catchError: " + ex.toString());
});
}
void logOut() async {
await dcoupon.logOut();
setState(() {
layoutLoginVisible = true;
});
}
@override
void setState(fn) {
super.setState(fn);
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: new Center(
child: _bodyForm(),
),
);
}
String _currentMethod;
void _changedDrowDownCurrentMethod(String itemSelected) {
setState(() {
_currentMethod = itemSelected;
startVisible = false;
limitVisible = false;
sortByVisible = false;
couponIdVisible = 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;
redemptionIdVisible = false;
gtmTimeZoneOffsetVisible = false;
groupByVisible = false;
startDateVisible = false;
endDateVisible = false;
affiliateApiTokenVisible = false;
cardNumberVisible = false;
switch (_currentMethod) {
case Constants.GET_USER_DATA:
break;
case Constants.UPDATE_USER_DATA:
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.GET_REDEMPTION_CODE:
break;
case Constants.GET_REDEMPTION_DETAIL:
redemptionIdVisible = true;
break;
case Constants.GET_REDEMPTION_HISTORY:
limitVisible = true;
startDateVisible = true;
endDateVisible = true;
gtmTimeZoneOffsetVisible = true;
break;
case Constants.GET_REDEMPTION_SUMMARY:
groupByVisible = true;
startDateVisible = true;
endDateVisible = true;
gtmTimeZoneOffsetVisible = 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.CREATE_COUPONS:
promotionTokensVisible = true;
longitudeVisible = true;
latitudeVisible = true;
sourceVisible = true;
transIdVisible = true;
crmIdVisible = true;
break;
case Constants.GET_COUPONS_COMPANIES:
break;
case Constants.GET_COUPONS_RETAILERS:
break;
case Constants.GET_CATEGORIES:
startVisible = true;
limitVisible = true;
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;
break;
case Constants.GET_PROMOTION_DETAIL:
promotionTokenVisible = true;
break;
case Constants.GET_STORES:
startVisible = true;
limitVisible = true;
promotionTokenVisible = true;
zipcodeVisible = true;
radiusVisible = true;
latitudeVisible = true;
longitudeVisible = true;
retailerTokensVisible = true;
orderByVisible = true;
break;
case Constants.GET_REDEMPTION_DETAIL:
redemptionIdVisible = true;
gtmTimeZoneOffsetVisible = true;
break;
default:
break;
}
});
}
void _launchMethod() {
setState(() {
_responseMsg = "";
try {
couponId = int.parse(couponId).toString();
} catch (ex) {
couponId = '0';
}
try {
start = int.parse(start).toString();
} catch (ex) {
start = '0';
}
try {
limit = int.parse(limit).toString();
} catch (ex) {
limit = '0';
}
try {
gtmTimeZoneOffset = int.parse(gtmTimeZoneOffset).toString();
} catch (ex) {
gtmTimeZoneOffset = '0';
}
switch (_currentMethod) {
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(alias, gender, birthdate).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: int.parse(start),
limit: int.parse(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(int.parse(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(int.parse(couponId)).then((response) {
_printMessage(Constants.ACTIVATE_COUPON, response);
}).catchError((ex) {
print("example.app.activateCoupon.catchError: " + ex.toString());
});
break;
case Constants.DEACTIVATE_COUPON:
dcoupon.deactivateCoupon(int.parse(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,
source: source,
transId: transId,
crmId: crmId,
publisherName: publisherName)
.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: int.parse(limit),
startDate: startDate,
endDate: endDate,
gmtTimeZoneOffset: int.parse(gtmTimeZoneOffset))
.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: int.parse(gtmTimeZoneOffset))
.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: int.parse(gtmTimeZoneOffset))
.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(
start: int.parse(start),
limit: int.parse(limit),
publisherName: publisherName)
.then((response) {
_printMessage(Constants.GET_CATEGORIES, response);
}).catchError((ex) {
print("example.app.getFilters.catchError: " + ex.toString());
});
break;
case Constants.GET_COMPANIES:
dcoupon
.getCompanies(
start: int.parse(start),
limit: int.parse(limit),
publisherName: publisherName)
.then((response) {
_printMessage(Constants.GET_COMPANIES, response);
}).catchError((ex) {
print("example.app.getFilters.catchError: " + ex.toString());
});
break;
case Constants.GET_RETAILERS:
dcoupon
.getRetailers(
start: int.parse(start),
limit: int.parse(limit),
publisherName: publisherName)
.then((response) {
_printMessage(Constants.GET_RETAILERS, response);
}).catchError((ex) {
print("example.app.getFilters.catchError: " + ex.toString());
});
break;
case Constants.GET_PROMOTIONS:
dcoupon
.getPromotions(
start: int.parse(start),
limit: int.parse(limit),
longitude: longitude,
latitude: latitude,
zipcode: zipcode,
retailerTokens: retailerTokens,
orderBy: orderBy,
radius: radius,
textSearch: textSearch,
companyTokens: companyTokens,
storeIds: storeIds,
categoryIds: categoryIds,
publisherName: publisherName)
.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, publisherName: publisherName)
.then((response) {
_printMessage(Constants.GET_PROMOTION_DETAIL, response);
}).catchError((ex) {
print("dcoupon.getPromotionDetail.catchError: " + ex.toString());
});
break;
case Constants.GET_STORES:
dcoupon
.getStores(
start: int.parse(start),
limit: int.parse(limit),
promotionToken: promotionToken,
retailerTokens: retailerTokens,
zipcode: zipcode,
latitude: latitude,
longitude: longitude,
radius: radius,
publisherName: publisherName)
.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>[
new Image(
fit: BoxFit.scaleDown,
image: new AssetImage('lib/assets/images/example_dcoupon_logo.png'),
),
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: email,
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(
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(
initialValue: alias,
decoration: InputDecoration(
labelText: Translations.of(context)
.text('example_alias')),
onChanged: (text) {
alias = text;
},
validator: (value) {
if (value.isEmpty) {
return (Translations.of(context).text(
'example_missed_parameter') +
" " +
Translations.of(context)
.text('example_alias'));
}
return null;
},
),
TextFormField(
initialValue: gender,
decoration: InputDecoration(
labelText: Translations.of(context)
.text('example_gender')),
onChanged: (text) {
gender = text;
},
validator: (value) {
if (value.isEmpty) {
return (Translations.of(context).text(
'example_missed_parameter') +
" " +
Translations.of(context)
.text('example_gender'));
}
return null;
},
),
TextFormField(
initialValue: birthdate,
decoration: InputDecoration(
labelText: Translations.of(context)
.text('example_birthdate')),
onChanged: (text) {
birthdate = text;
},
validator: (value) {
if (value.isEmpty) {
return (Translations.of(context).text(
'example_missed_parameter') +
" " +
Translations.of(context)
.text('example_birthdate'));
}
return null;
},
),
],
),
),
)
],
),
Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
RaisedButton(
onPressed: login,
color: Colors.blue,
child: Row(
children: <Widget>[
Text(Translations.of(context)
.text('example_button_login'))
],
),
)
],
)
])),
Visibility(
visible: !layoutLoginVisible,
child: Container(
child: Column(
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Column(
children: <Widget>[
Row(
children: <Widget>[
RichText(
text: TextSpan(
text: Translations.of(context).text(
'example_text_welcome') +
", " +
email,
style: TextStyle(
fontStyle: FontStyle.normal,
fontSize: 20,
color: Colors.black)),
overflow: TextOverflow.fade,
),
],
),
Row(
children: <Widget>[
RaisedButton(
onPressed: logOut,
color: Colors.blue,
child: Row(
children: <Widget>[
Text(Translations.of(context)
.text('example_button_logout'))
],
),
)
],
),
],
),
],
)
],
),
),
),
Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Expanded(
child: Container(
child: Column(
children: <Widget>[
Visibility(
visible: startVisible,
child: TextFormField(
initialValue: start,
decoration:
InputDecoration(labelText: 'start'),
onChanged: (text) {
start = text;
},
),
),
Visibility(
visible: limitVisible,
child: TextFormField(
initialValue: limit,
decoration:
InputDecoration(labelText: 'limit'),
onChanged: (text) {
limit = text;
},
),
),
Visibility(
visible: sortByVisible,
child: TextFormField(
initialValue: sortBy,
decoration:
InputDecoration(labelText: 'sortBy'),
onChanged: (text) {
sortBy = text;
},
),
),
Visibility(
visible: couponIdVisible,
child: TextFormField(
initialValue: couponId,
decoration:
InputDecoration(labelText: 'couponId'),
onChanged: (text) {
couponId = 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: redemptionIdVisible,
child: TextFormField(
initialValue: redemptionId,
decoration: InputDecoration(
labelText: 'redemptionId'),
onChanged: (text) {
redemptionId = text;
},
),
),
Visibility(
visible: gtmTimeZoneOffsetVisible,
child: TextFormField(
initialValue: gtmTimeZoneOffset,
decoration: InputDecoration(
labelText: 'gtmTimeZoneOffset'),
onChanged: (text) {
gtmTimeZoneOffset = 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;
},
),
),
],
),
),
)
],
),
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_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: _changedDrowDownCurrentMethod,
),
RaisedButton(
onPressed: _launchMethod,
color: 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))),
],
),
),
)
],
)
],
))),
],
),
);
}
}