import 'package:flutter/material.dart'; import 'package:flutter_openim_sdk/flutter_openim_sdk.dart'; void main() { try { runApp(MyApp()); } catch (e, stackTrace) { print('Error during app startup: $e'); print('Stack trace: $stackTrace'); } } class MyApp extends StatefulWidget { @override _MyAppState createState() => _MyAppState(); } class _MyAppState extends State { @override void initState() { super.initState(); OpenIM.iMManager .initSDK( platformID: 1, apiAddr: 'http://192.168.77.135:10002', wsAddr: 'ws://192.168.77.135:10001', dataDir: './', listener: OnConnectListener()) .then((value) { print('SDK initialized successfully'); OpenIM.iMManager .login( userID: "3e8b8fb2ecd8414db50838d9f7bcb19d", token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySUQiOiIzZThiOGZiMmVjZDg0MTRkYjUwODM4ZDlmN2JjYjE5ZCIsIlBsYXRmb3JtSUQiOjIsImV4cCI6MTc1Mzc1MTYyNywiaWF0IjoxNzQ1OTc1NjIyfQ.S-CxfETXYyLFe2VqStwbrVCRcB5j2T2qi-52y1L-3OI") .then((value) { print('Login successful'); }).catchError((error) { print('Login failed: $error'); }); }); } @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar( title: const Text('Plugin example app'), ), body: Column( children: [ TextButton(onPressed: () {}, child: Text('login')), ], ), ), ); } }