67 lines
1.7 KiB
Dart
67 lines
1.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
|
|
class BankView extends StatefulWidget {
|
|
BankView();
|
|
|
|
@override
|
|
_BankViewState createState() => _BankViewState();
|
|
}
|
|
|
|
class _BankViewState extends State<BankView> {
|
|
static const MethodChannel _channel =
|
|
MethodChannel('channel:com.amanKassa/bank');
|
|
static const MethodChannel _activity =
|
|
MethodChannel('channel:com.amanKassa/activity');
|
|
String value;
|
|
bool loading = false;
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
load();
|
|
}
|
|
|
|
load() async {
|
|
setState(() {
|
|
loading = true;
|
|
});
|
|
String result = await _channel.invokeMethod('ping');
|
|
|
|
setState(() {
|
|
value = result ?? 'none';
|
|
loading = false;
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
centerTitle: true,
|
|
title: Text('Банковская страница'),
|
|
),
|
|
body: loading
|
|
? Container(child: Center(child: CircularProgressIndicator()))
|
|
: SingleChildScrollView(
|
|
child: Column(
|
|
children: <Widget>[
|
|
Container(
|
|
margin: const EdgeInsets.all(8.0),
|
|
child: Text(value),
|
|
),
|
|
RaisedButton(
|
|
child: Text('Press'),
|
|
onPressed: () async {
|
|
String result = await _activity.invokeMethod("start");
|
|
print('invokeMethod: $result');
|
|
setState(() {
|
|
loading = false;
|
|
});
|
|
})
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|