android MusicPlugin.java
parent
8d6ec6bfe1
commit
44e85646fd
|
|
@ -0,0 +1,34 @@
|
|||
package com.example.aman_kassa_flutter.bank;
|
||||
|
||||
import android.content.Intent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.flutter.plugin.common.MethodCall;
|
||||
import io.flutter.plugin.common.MethodChannel;
|
||||
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
|
||||
import io.flutter.plugin.common.MethodChannel.Result;
|
||||
|
||||
public class MusicPlugin implements MethodCallHandler {
|
||||
@Override
|
||||
public void onMethodCall(MethodCall call, Result result) {
|
||||
switch (call.method) {
|
||||
case "ping":
|
||||
|
||||
result.success("pong - 3");
|
||||
break;
|
||||
case "get":
|
||||
final List<Object> json = new ArrayList<>();
|
||||
for (int i =0; i < 2 ; i++) {
|
||||
json.add("{\"name:\":\"test\" }"); // Map<String, Object> entries
|
||||
}
|
||||
result.success(json);
|
||||
break;
|
||||
default:
|
||||
result.notImplemented();
|
||||
}
|
||||
}
|
||||
|
||||
// Other methods elided.
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
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;
|
||||
});
|
||||
})
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue