mm_component 0.0.17
mm_component: ^0.0.17 copied to clipboard
MM login component plugin project.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:mm_component/mm_component.dart';
void main() {
runApp(MaterialApp(home: MyApp()));
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String response = '';
final String mmUrl = "http://172.16.116.92:8081/bumm/mm-light"; //tests
// final String mmUrl = "https://customer.mostmoney.mn:9091/bumm/bid"; //prod
final String appVersion = "85";
@override
void initState() {
super.initState();
initPlatformState();
}
Future<void> initPlatformState() async {
await MmComponent.open(
operation: MmComponent.KEY_NAVIGATION_LOGIN,
version: appVersion,
url: mmUrl,
onSuccess: onSuccess,
onGoto: onGoto,
failAlertMode: MmComponent.MODE_TOAST,
entityCode: '1',
appBarMode: MmComponent.VISIBLE
// onFail: onFail, [ optional ]
// onRedirect: onRedirect, [ optional ]
);
}
void onSuccess(String result) {
// login success and recieve user data
setState(() {
response = "onSuccess: $result";
});
}
void onGoto(String result) {
// call other page
setState(() {
response = "onGoto: $result";
});
}
void onFail(String result) async {
// [ optional ]
}
void onRedirect(String result) {
// [ optional ]
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('MM Component plugin example app'),
),
body: Center(
child: Text('$response'),
),
),
);
}
}