woosignal_shopify 1.1.0
woosignal_shopify: ^1.1.0 copied to clipboard
WooSignal Flutter plugin for the Shopify StoreMob app template
example/main.dart
import 'package:flutter/material.dart';
import 'package:woosignal_shopify/models/shopify_product.dart';
import 'package:woosignal_shopify/woosignal_shopify.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'WooSignal Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'WooSignal Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
String _productName = "";
_incrementCounter() async {
ShopifyProduct shopifyProduct = await ShopifyAPI.instance
.service((request) => request.fetchProducts(limit: 50));
print(shopifyProduct.products[0].title);
setState(() {
_productName = shopifyProduct.products[0].title;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'WooCommerce product :',
),
Text(
_productName,
style: Theme.of(context).textTheme.display1,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.lightbulb_outline),
),
);
}
}