wecom_auth_plus 0.0.1
wecom_auth_plus: ^0.0.1 copied to clipboard
Flutter plugin for WeCom (Enterprise WeChat) auth. Supports configure, app-installed check, register, auth, and auto login flow.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:wecom_auth_plus/wecom_auth_plus.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
final _plugin = WecomAuthPlus();
String _log = 'Ready';
Future<void> _configure() async {
await _plugin.configure(
scheme: 'wwauth_xxx',
corpId: 'wwxxxxxxxx',
agentId: '1000001',
);
setState(() => _log = 'Configured');
}
Future<void> _isInstalled() async {
final r = await _plugin.isAppInstalled();
setState(() => _log = 'isInstalled: ${r.raw}');
}
Future<void> _register() async {
final r = await _plugin.register();
setState(() => _log = 'register: ${r.raw}');
}
Future<void> _auth() async {
final r = await _plugin.auth(state: 'example_state');
setState(() => _log = 'auth: ${r.raw}');
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Padding(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
ElevatedButton(
onPressed: _configure,
child: const Text('1. configure'),
),
const SizedBox(height: 12),
ElevatedButton(
onPressed: _isInstalled,
child: const Text('2. isAppInstalled'),
),
const SizedBox(height: 12),
ElevatedButton(
onPressed: _register,
child: const Text('3. register'),
),
const SizedBox(height: 12),
ElevatedButton(
onPressed: _auth,
child: const Text('4. auth'),
),
const SizedBox(height: 20),
Expanded(
child: SingleChildScrollView(
child: Text(_log),
),
),
],
),
),
),
);
}
}