import
'package:flutter/material.dart'
;
void
main() {
runApp(
const
MyApp());
}
class
MyApp extends StatelessWidget {
const
MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return
MaterialApp(
title:
'Flutter Demo'
,
theme: ThemeData(
primarySwatch: Colors.green,
),
home:
const
MyHomePage(),
);
}
}
class
MyHomePage extends StatefulWidget {
const
MyHomePage({
Key? key,
}) : super(key: key);
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class
_MyHomePageState extends State<MyHomePage> {
bool
isLoading =
false
;
@override
Widget build(BuildContext context) {
return
Scaffold(
appBar: AppBar(
backgroundColor: Colors.green,
title:
const
Text(
'GeeksforGeeks'
,style: TextStyle(color: Colors.white),),
centerTitle:
true
,
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
padding:
const
EdgeInsets.only(left: 10, right: 10),
width: MediaQuery.of(context).size.width,
height: 60,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.green
),
onPressed: () {
setState(() {
isLoading =
true
;
});
Future.delayed(
const
Duration(seconds: 3), (){
setState(() {
isLoading =
false
;
});
}
);
}, child: isLoading? Row(
mainAxisAlignment: MainAxisAlignment.center,
children:
const
[
Text(
'Loading...'
, style: TextStyle(fontSize: 20),),
SizedBox(width: 10,),
CircularProgressIndicator(color: Colors.white,),
],
) :
const
Text(
'Submit'
),
)
)
],
),
),
);
}
}