pattern_dots 0.0.2-alpha copy "pattern_dots: ^0.0.2-alpha" to clipboard
pattern_dots: ^0.0.2-alpha copied to clipboard

A pattern lock UI using flutter.

example/lib/main.dart

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:pattern_dots/pattern_dots.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue),
        useMaterial3: true,
      ),
      home: const HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  PatternLockStyle _lockStyle = PatternLockStyle.normal;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: Center(
        child: PatternStyle(
          data: PatternStyleData(
            tapRange: 24,
          ),
          child: PatternView(
            lockStyle: _lockStyle,
            onTapDown: () {
              _lockStyle = PatternLockStyle.normal;
              setState(() {});
            },
            onComplete: (cells) {
              bool same = !listEquals(cells, [0, 4, 5, 8]);
              _lockStyle =
                  same ? PatternLockStyle.success : PatternLockStyle.failed;
              setState(() {});
            },
          ),
        ),
      ),
    );
  }
}
1
likes
0
points
17
downloads

Publisher

verified publisherlaihz.tech

Weekly Downloads

A pattern lock UI using flutter.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on pattern_dots