better_pattern_lock 1.0.1 copy "better_pattern_lock: ^1.0.1" to clipboard
better_pattern_lock: ^1.0.1 copied to clipboard

A pattern lock for Flutter. Just like in your old Samsung device, but this one is much more customizable.

example/lib/main.dart

import 'dart:math' as math;

import 'package:better_pattern_lock/better_pattern_lock.dart';
import 'package:flutter/material.dart';

part 'var1.dart';
part 'var2.dart';
part 'var3.dart';

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

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

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

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

  @override
  State<PatternLockScreen> createState() => _PatternLockScreenState();
}

class _PatternLockScreenState extends State<PatternLockScreen> {
  int x = 3;
  int y = 3;
  final colors = <int>[];
  final r = math.Random();

  final c = PageController(initialPage: 0);

  @override
  void dispose() {
    c.dispose();
    super.dispose();
  }

  @override
  void initState() {
    for (int i = 0; i < x * y; i++) {
      colors.add(0xff000000 + r.nextInt(0x00ffffff));
    }
    super.initState();
  }

  @override
  void setState(VoidCallback fn) {
    super.setState(fn);
    colors.clear();
    for (int i = 0; i < x * y; i++) {
      colors.add(0xff000000 + r.nextInt(0x00ffffff));
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: ListenableBuilder(
          listenable: c,
          builder: (ctx, _) {
            final title = switch (c.page?.round() ?? 0) {
              0 => 'Default Implementation',
              1 => 'Custom cells and connections',
              2 => 'Custom cells, connections, link rules, dynamic dimensions',
              _ => '',
            };
            return Text(
              title,
              maxLines: 3,
              textAlign: TextAlign.center,
            );
          },
        ),
        toolbarHeight: 100.0,
        centerTitle: true,
      ),
      body: SafeArea(
        child: PageView(
          controller: c,
          padEnds: true,
          children: [
            const Padding(
              padding: EdgeInsets.symmetric(
                horizontal: 35.0,
              ),
              child: Center(
                child: Variant1(),
              ),
            ),
            const Padding(
              padding: EdgeInsets.symmetric(
                horizontal: 35.0,
              ),
              child: Center(child: Variant2()),
            ),
            Padding(
              padding: const EdgeInsets.symmetric(
                horizontal: 35.0,
              ),
              child: Center(
                child: Column(
                  mainAxisSize: MainAxisSize.min,
                  children: [
                    Variant3(
                      x: x,
                      y: y,
                      colors: colors,
                    ),
                    Slider(
                      value: x.toDouble(),
                      onChanged: (val) {
                        setState(() {
                          x = val.toInt();
                        });
                      },
                      min: 1.0,
                      max: 10.0,
                      divisions: 10,
                    ),
                    Slider(
                      value: y.toDouble(),
                      onChanged: (val) {
                        setState(() {
                          y = val.toInt();
                        });
                      },
                      min: 1.0,
                      max: 10.0,
                      divisions: 10,
                    ),
                  ],
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
11
likes
150
points
45
downloads

Publisher

verified publisheralt-point.com

Weekly Downloads

A pattern lock for Flutter. Just like in your old Samsung device, but this one is much more customizable.

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

flutter

More

Packages that depend on better_pattern_lock