51 lines
1.5 KiB
Dart
51 lines
1.5 KiB
Dart
import 'dart:convert';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'package:flutter_provisioning_for_iot/objects/cloud_service_api.dart';
|
|
import 'package:flutter_provisioning_for_iot/widgets/sidebar.dart';
|
|
|
|
|
|
class CloudService extends StatefulWidget {
|
|
const CloudService({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<CloudService> createState() => _CloudService();
|
|
|
|
}
|
|
Future<Map<String, dynamic>> readJson() async {
|
|
final data = await rootBundle.loadString('config/credentials.json');
|
|
var data_ = json.decode(data) as Map<String, dynamic>;
|
|
debugPrint(data_.toString());
|
|
return data_;
|
|
}
|
|
|
|
class _CloudService extends State<CloudService>{
|
|
|
|
late final Map<String, dynamic> credentials;
|
|
final CloudServiceAPI cloudServiceAPI = CloudServiceAPI();
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: const Text("Cloud Service"),
|
|
),
|
|
body: Center(
|
|
child: TextButton(
|
|
onPressed: () async{
|
|
var respond1 = await cloudServiceAPI.getDevices();
|
|
debugPrint('Devices: ${respond1.toString()}');
|
|
var respond2 = await cloudServiceAPI.getInformation();
|
|
debugPrint('Information: ${respond2.toString()}');
|
|
var respond3 = await cloudServiceAPI.createDevice('1', 'asdas', 'sdwe1');
|
|
debugPrint('CreateDevice: ${respond3.toString()}');
|
|
}, child: const Text("Example"),
|
|
),
|
|
),
|
|
drawer: const Sidebar(),
|
|
);
|
|
}
|
|
|
|
} |