flutter_checkbox_dialog 0.0.1 copy "flutter_checkbox_dialog: ^0.0.1" to clipboard
flutter_checkbox_dialog: ^0.0.1 copied to clipboard

Package for integrating "CheckboxListTile" into "AlertDialog".

example/lib/main.dart

import 'package:flutter/material.dart';

import 'package:flutter_checkbox_dialog/flutter_checkbox_dialog.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'sample_flutter_checkbox_dialog',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key}) : super(key: key);

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  var checkboxValue = false;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('sample_flutter_checkbox_dialog'),
      ),
      body: Center(
        child: TextButton(
          onPressed: () async {
            await FlutterCheckboxDialog().showCheckboxDialog(
              context,
              checkboxValue,
              const Text('次回から確認しない'),
              _onChanged,
              title: const Text('確認ダイアログ'),
              content: const Text('※この操作は取り消せません。'),
              actions: [
                TextButton(
                  onPressed: () {
                    Navigator.of(context).pop();
                  },
                  child: const Text('OK'),
                ),
                TextButton(
                  onPressed: () {
                    Navigator.of(context).pop();
                  },
                  child: const Text('キャンセル'),
                ),
              ],
            );
          },
          child: const Text('ダイアログを開く'),
        ),
      ),
    );
  }

  void _onChanged(bool value) {
    setState(() {
      checkboxValue = value;
    });
  }
}
0
likes
110
pub points
1%
popularity

Publisher

verified publisherhondakenya.work

Package for integrating "CheckboxListTile" into "AlertDialog".

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_checkbox_dialog