ip_address_keypad 1.0.1
ip_address_keypad: ^1.0.1 copied to clipboard
A custom inline numeric keypad and text field designed for seamless IPv4 address entry on both mobile and custom landscape form factors.
import 'package:flutter/material.dart';
import 'package:ip_address_keypad/ip_address_keypad.dart';
void main() {
runApp(const MyApp());
}
/// The main application widget for the example.
class MyApp extends StatelessWidget {
/// Creates the [MyApp] widget.
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'IP Address Keypad Example',
theme: ThemeData(
useMaterial3: true,
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
),
home: const HomeScreen(),
);
}
}
/// The home screen widget that demonstrates the [IpAddressInput] widget.
class HomeScreen extends StatefulWidget {
/// Creates the [HomeScreen] widget.
const HomeScreen({super.key});
@override
State<HomeScreen> createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
String _enteredIp = '';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('IP Address Keypad Example')),
body: SafeArea(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const Text(
'Enter IPv4 Address:',
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
),
const SizedBox(height: 16),
IpAddressInput(
onCompleted: (ip) {
setState(() {
_enteredIp = ip;
});
},
),
const SizedBox(height: 32),
Card(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Text(
'Current Value: $_enteredIp',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
color: Theme.of(context).colorScheme.primary,
),
textAlign: TextAlign.center,
),
),
),
],
),
),
),
);
}
}