Last updated:
0 purchases
isprime
A Dart package for prime number checking #
The isprime package offers a simple and efficient way to check if a given number is prime. Designed for Dart and Flutter developers, this package provides a straightforward function that takes an integer as input and returns a boolean indicating whether the number is a prime number. It's optimized for performance and ease of use, making it an ideal choice for applications requiring prime number validation, mathematical computations, and educational purposes. Incorporating isprime into your project will streamline your development process when dealing with number theory-related tasks.
Authors #
Nazmul Haque Nahin
Features #
It will take input an integer and then return a boolean value
It's not complex
Easy to implement
FAQ #
1.Can isprime handle very large numbers?
Ans : The package is optimized for performance but is subject to Dart's limitations on integer sizes. Now its OK for 3 digit.
Is isprime suitable for educational purposes?
Ans : Absolutely! It's a great tool for learning about prime numbers and algorithms in a practical setting.
Demo
To see isprime in action, here is a simple Flutter app snippet:
import 'package:flutter/material.dart';
import 'package:isprime/isprime.dart';
class HomePage extends StatefulWidget {
const HomePage({super.key});
@override
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
int inputNumber = 0;
CheckPrime primeChecker = CheckPrime();
TextEditingController editingController = TextEditingController();
void checkPrime(int value)
{
print("${primeChecker.isPrime(value)}");
setState(() {
inputNumber = value;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Prime Checker"),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("$inputNumber is prime : ${primeChecker.isPrime(inputNumber)}"),
TextField(
maxLength: 3,
keyboardType: TextInputType.number,
controller: editingController,
onChanged: (text) {
Future.delayed(const Duration(milliseconds: 500),(){
if(text.isNotEmpty){
checkPrime(int.parse(text));
}
});
})
]
)
)
);
}
}
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.