woosignal 1.1.1 woosignal: ^1.1.1 copied to clipboard
WooCommerce REST API for dart, connect a WooCommerce store and start developing with our interface for their API endpoints.
import 'package:flutter/material.dart';
import 'package:woosignal/models/response/products.dart';
import 'package:woosignal/woosignal.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 {
// CONFIG FOR WOOSIGNAL
var wsConfig = {"appKey": "your app key", "debugMode": true};
// CREATING AN INSTANCE
WooSignal wooSignal = await WooSignal.getInstance(config: wsConfig);
List<Product> products = await wooSignal.getProducts();
print(products[0].name);
setState(() {
_productName = products[0].name;
});
}
@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),
),
);
}
}