boltiot 0.0.4 boltiot: ^0.0.4 copied to clipboard
boltiot dart package for interacting with bolt cloud and wifi module.
import 'package:flutter/material.dart';
import 'package:boltiot/boltiot.dart';
import 'package:http/http.dart' as http;
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
String output='';
@override
Widget build(BuildContext context) {
Bolt myBolt = new Bolt('API_ID','DEVICE_ID');//declaring Bolt object named myBolt
return Scaffold(
appBar: AppBar(title: Text('Example'),),
body: Container(
width: double.infinity,
height: double.infinity,
color: Colors.redAccent,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
RaisedButton(
child: Text('Press'),
onPressed: ()async{
await myBolt.isOnline().then(
(value){
setState(() {
output = value.body;
//print(output);
});
}
);
}
),
Container(
height: 200,
width: 250,
color: Colors.white,
child: Text('$output',
),
)
],
),
),
);
}
}