// 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({Key? key, required this.message, required this.screenKey}) : super(key: key); @override _HelperDialogState createState() => _HelperDialogState(); } class _HelperDialogState extends State { bool _doNotShowAgain = false; @override Widget build(BuildContext context) { return AlertDialog( title: Row( children: [ Icon(Icons.help_outline, color: Colors.blue), SizedBox(width: 10), Text('ヘルプ'), ], ), content: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text(widget.message), SizedBox(height: 20), Row( children: [ Checkbox( value: _doNotShowAgain, onChanged: (value) { setState(() { _doNotShowAgain = value!; }); }, ), Text('この画面を二度と表示しない'), ], ), ], ), actions: [ TextButton( child: 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)); } }