IF Else And Nested IF Else Conditional Statement
Complete Code For IF Else And Nested IF Else Conditional Statement In Flutter
main.dart
import 'package:flutter/material.dart';
void main(){
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateMixin {
void checkMethodSimple(int value) {
if(value > 200)
{
print('Value is Bigger than 200');
}
else{
print('Value is Smaller than 200');
}
}
void checkMethodNested(int value){
if( value > 200 )
{
print("Value is Grater than 200.");
}
else if(value < 200)
{
print("Value is Less than 200.");
}
else if(value == 200)
{
print("Entered Value is 200");
}
else
{
print("Sorry, Value not matched.");
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.lightGreen,
title: Text('If Else & Nested IF Else Conditional Statement'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
child: RaisedButton(
onPressed: () => checkMethodSimple(7),
child: Text('Call Simple IF-Condition'),
textColor: Colors.white,
color: Colors.green,
)
),
Container(
child: RaisedButton(
onPressed: () => checkMethodNested(200),
child: Text('Call Nested IF-Condition'),
textColor: Colors.white,
color: Colors.indigo,
)
)
])
)
);
}
}