traknplugin 0.0.1 traknplugin: ^0.0.1 copied to clipboard
A new Flutter plugin.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:traknplugin/traknplugin.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _payAmount = 'Unknown';
@override
void initState() {
super.initState();
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initTraknPay(String amount) async {
String amount;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
amount = await Traknplugin.platformVersion;
} on PlatformException {
amount = 'Failed to get initiate.';
}
// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
if (!mounted) return;
setState(() {
_payAmount = amount;
});
}
@override
Widget build(BuildContext context) {
TextEditingController nameController = TextEditingController();
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Trakn Pay'),
),
body: Padding(
padding: EdgeInsets.all(10),
child: ListView(
children: <Widget>[
Container(
alignment: Alignment.center,
padding: EdgeInsets.all(10),
child: Text(
'Welcome TraknPay',
style: TextStyle(
color: Colors.blue,
fontWeight: FontWeight.w500,
fontSize: 30),
)),
Container(
padding: EdgeInsets.all(10),
child: TextField(
controller: nameController,
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'Amount',
),
),
),
Container(
height: 50,
padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
child: RaisedButton(
textColor: Colors.white,
color: Colors.blue,
child: Text('Pay'),
onPressed: () {
initTraknPay(nameController.text);
},
)),
Container(
alignment: Alignment.center,
padding: EdgeInsets.all(10),
child: Text(
'Paid Amount : '+ _payAmount,
style: TextStyle(
color: Colors.blue,
fontWeight: FontWeight.w500,
fontSize: 20),
))
],
)),
),
);
}
}