const projectApiToken = String.fromEnvironment('GEM_TOKEN');
void main() async {
Debug.logCallObjectMethod = false;
Debug.logCreateObject = true;
Debug.logLevel = GemLoggingLevel.all;
Debug.logListenerMethod = true;
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Send Debug Info',
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
void dispose() {
GemKit.release();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.deepPurple[900],
title: const Text(
'Send Debug Info',
style: TextStyle(color: Colors.white),
),
actions: [
IconButton(
onPressed: _shareLogs,
icon: const Icon(Icons.share, color: Colors.white),
),
],
),
body: GemMap(
key: ValueKey("GemMap"),
appAuthorization: projectApiToken,
onMapCreated: (ctrl) async {
await Debug.setSdkDumpLevel(GemDumpSdkLevel.verbose);
final dartSdkLogger = Logger('GemSdkLogger');
dartSdkLogger.onRecord.listen((record) {
Debug.log(level: GemDumpSdkLevel.verbose, message: '${record.time} ${record.message}');
});
},
),
);
}
Future<void> _shareLogs() async {
final logPath = await Debug.getSdkLogDumpPath();
await SharePlus.instance.share(ShareParams(files: [XFile(logPath)]));
}
}