Find Minimum Number Value Between Two Numbers In Flutter

admin_img Posted By Bajarangi soft , Posted On 12-10-2020

In our previous tutorial we have discuss about finding maximum number between two numbers. Current tutorial is just opposite of that tutorial. In today’s tutorial we would discuss about finding minimum number between two numbers in flutter using min<T extends num> function. The min() method is already given in dart in math package. We can use it by importing ‘dart:math’ class in our flutter project.

Find Minimum Number Value Between Two Numbers In Flutter

Minimum Number Value Between Two Numbers 
Complete Code For Minimum Number Value Between Two Numbers  In Flutter
Main.dart

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

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  int Number_A = 220;
  int Number_B = 330;
  int Number_C;

  findMinBetween2Values() {
    Number_C = min(Number_A, Number_B);
    print(Number_C);
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
        home: Scaffold(
          appBar: AppBar(
            backgroundColor: Colors.lightGreen,
            title: Text("Minimum Value Between 2 Numbers"),
          ),
            body: Center(
                child: Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: <Widget>[
                      Container(
                          margin: const EdgeInsets.fromLTRB(20, 10, 20, 10),
                          child: RaisedButton(
                            onPressed: () => findMinBetween2Values(),
                            child: Text(' Find Minimum Value Between 2 Numbers '),
                            textColor: Colors.white,
                            color: Color(0xFFFFC107),
                            padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
                          )),
                    ]
                )
            )
        )
    );
  }
}

Related Post