Commit df26a400 authored by Rajasingam kokilan's avatar Rajasingam kokilan

main

parent 58900705
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'tank water level analysier from raspery pi',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Tank water level from raspery pi'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
static const platform =
const MethodChannel('samples.flutter.dev/connect wit rasperypi');
String _tankLevel = 'you can find water level heair.';
Future<void> _gettankLevel() async {
String tankLevel;
try {
final int result = await platform.invokeMethod('gettankLevel');
tankLevel = 'tank level at $result % .';
} on PlatformException catch (e) {
tankLevel = "Failed to get tank level: '${e.message}'.";
}
setState(() {
_tankLevel = _tankLevel;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
// horizontal).
mainAxisAlignment: MainAxisAlignment.center,
//padding: new EdgeInsets.all(20),
children: <Widget>[
Text(
_tankLevel,
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20.0),
),
],
),
),
floatingActionButton: Padding(
child: FloatingActionButton.extended(
elevation: 4.0,
//icon: const Icon(Icons.add),
label: const Text('Get tank level'),
onPressed: _gettankLevel,
),
padding: new EdgeInsets.only(bottom: 20),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment