import 'package:flutter/material.dart'; class MPinScreen extends StatefulWidget { const MPinScreen({super.key}); @override MPinScreenState createState() => MPinScreenState(); } class MPinScreenState extends State { List mPin = []; void addDigit(String digit) { if (mPin.length < 4) { setState(() { mPin.add(digit); }); } } void deleteDigit() { if (mPin.isNotEmpty) { setState(() { mPin.removeLast(); }); } } Widget buildMPinDots() { return Row( mainAxisAlignment: MainAxisAlignment.center, children: List.generate(4, (index) { return Container( margin: const EdgeInsets.all(8), width: 15, height: 15, decoration: BoxDecoration( shape: BoxShape.circle, color: index < mPin.length ? Colors.black : Colors.grey[400], ), ); }), ); } Widget buildNumberPad() { List> keys = [ ['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9'], ['', '0', '<'] ]; return Column( children: keys.map((row) { return Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: row.map((key) { return Padding( padding: const EdgeInsets.all(8.0), child: GestureDetector( onTap: () { if (key == '<') { deleteDigit(); } else if (key.isNotEmpty) { addDigit(key); } }, child: Container( width: 70, height: 70, decoration: BoxDecoration( shape: BoxShape.circle, color: Colors.grey[200], ), alignment: Alignment.center, child: Text( key == '<' ? '⌫' : key, style: const TextStyle(fontSize: 24), ), ), ), ); }).toList(), ); }).toList(), ); } @override Widget build(BuildContext context) { return Scaffold( body: SafeArea( child: Column( children: [ const Spacer(), // Logo const FlutterLogo(size: 100), const SizedBox(height: 20), const Text( "Enter your mPIN", style: TextStyle(fontSize: 20, fontWeight: FontWeight.w500), ), const SizedBox(height: 20), buildMPinDots(), const Spacer(), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ TextButton(onPressed: () {}, child: const Text("Try another way")), TextButton(onPressed: () {}, child: const Text("Register?")), ], ), buildNumberPad(), const Spacer(), ], ), ), ); } }