teachable 0.0.2 teachable: ^0.0.2 copied to clipboard
A new Flutter package project.
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:teachable/teachable.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Permission.camera.request();
await Permission.microphone.request();
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
String pose = "";
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("Pose Classifier")),
body: Stack(
children: [
Container(
child: Column(children: <Widget>[
Expanded(
child: Container(
child: Teachable(
path: "pose/index.html",
results: (res) {
var resp = jsonDecode(res);
// print("The values are ${}");
setState(() {
pose = (resp['Tree Pose'] * 100.0).toString();
});
},
),
),
),
])),
Align(
alignment: Alignment.bottomCenter,
child: Container(
width: double.infinity,
height: 50,
decoration: BoxDecoration(
color: Colors.black.withOpacity(0.5),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text(
"TREE POSE",
style: TextStyle(
color: Colors.white,
),
),
Text(
pose,
style: TextStyle(
color: Colors.white,
),
),
],
),
],
)),
)
],
));
}
}