📝

【Flutter】個人開発で利用規約・プライバシーポリシーを作成する

2023/12/07に公開

Notionで利用規約とプライバシーポリシーを作成する

notionはこちらから。
https://www.notion.so/

利用規約とプライバシーポリシーを作成する

今回は下記の雛形を参考に作成。
※適宜自分のサービスに合わせて内容を調整する必要あり。

利用規約
https://kiyaku.jp/hinagata/gp.html
プライバシーポリシー
https://kiyaku.jp/hinagata/privacy.html

作成した利用規約とプライバシーポリシーをPublishにする

右上のShareボタンからPublishに変更する。

FlutterでWebViewを実装する

url_launcherを使用
https://pub.dev/packages/url_launcher

packageのインストール

flutter pub add url_launcher

実装方法

iosはinfo.plistに下記を追加。すぐに反映されなければシミュレーターを再起動。

<key>LSApplicationQueriesSchemes</key>
<array>
      <string>sms</string>
      <string>tel</string>
</array>

urlを作成。

const url = 'https://zenn.dev/ryoya_fukasawa';
final uri = Uri.parse(url);

canLaunchUrlで指定されたURLがデバイスにインストールされているアプリで処理できるかどうかを確認。
launchUrlで実行。

if (await canLaunchUrl(uri)) {
  await launchUrl(uri);
}

具体例

RichText(
  textAlign: TextAlign.center,
  text: TextSpan(
    style: AppTypography.body.copyWith(
      color: AppColors.black,
    ),
    children: [
      const TextSpan(
        text: 'I agree to continue, acknowledging my consent to the ',
      ),
      TextSpan(
        text: 'terms of service',
        style: AppTypography.body.copyWith(
          color: Colors.blue,
          decoration: TextDecoration.underline,
        ),
        recognizer: TapGestureRecognizer()
          ..onTap = () async {
            const url =
                'https://zenn.dev/ryoya_fukasawa';
            final uri = Uri.parse(url);
            if (await canLaunchUrl(uri)) {
              await launchUrl(uri);
            }
          },
      ),
      const TextSpan(
        text: ' and ',
      ),
      TextSpan(
        text: 'privacy policy',
        style: AppTypography.body.copyWith(
          color: Colors.blue,
          decoration: TextDecoration.underline,
        ),
        recognizer: TapGestureRecognizer()
          ..onTap = () async {
            const url =
                'https://twitter.com/cyber_fukasawa';
            final uri = Uri.parse(url);
            if (await canLaunchUrl(uri)) {
              await launchUrl(uri);
            }
          },
      ),
      const TextSpan(
        text: '.',
      ),
    ],
  ),
),

Discussion