// lib/widgets/helper_dialog.dart import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:shared_preferences/shared_preferences.dart'; class HelperDialog extends StatefulWidget { final String message; final String screenKey; const HelperDialog({super.key, required this.message, required this.screenKey}); @override _HelperDialogState createState() => _HelperDialogState(); } class _HelperDialogState extends State { bool _doNotShowAgain = false; @override Widget build(BuildContext context) { return AlertDialog( title: const Row( children: [ Icon(Icons.help_outline, color: Colors.blue), SizedBox(width: 10), Text('ヘルプ'), ], ), content: SingleChildScrollView( child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text(widget.message), const SizedBox(height: 20), Row( children: [ Checkbox( value: _doNotShowAgain, onChanged: (value) { setState(() { _doNotShowAgain = value!; }); }, ), const Flexible( child: Text( 'この画面を二度と表示しない', overflow: TextOverflow.ellipsis, ), ), ], ), ], ), ), actions: [ TextButton( child: const Text('OK'), onPressed: () async { if (_doNotShowAgain) { final prefs = await SharedPreferences.getInstance(); await prefs.setBool('helper_${widget.screenKey}', false); } Get.back(); }, ), ], ); } } // ヘルパー画面を表示する関数 Future showHelperDialog(String message, String screenKey) async { final prefs = await SharedPreferences.getInstance(); final showHelper = prefs.getBool('helper_$screenKey') ?? true; if (showHelper) { Get.dialog( HelperDialog(message: message, screenKey: screenKey), barrierDismissible: false, ); } }