import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
// This widget is the root
// of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: GFG(),
debugShowCheckedModeBanner: false,
);
}
}
class GFG extends StatefulWidget {
const GFG({Key? key}) : super(key: key);
@override
State<GFG> createState() => _GFGState();
}
class _GFGState extends State<GFG> with TickerProviderStateMixin {
late AnimationController _controller;
bool _bool = true;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("GeeksForGeeks"),
actions: [
// Creating a button to
// switch between two widgets
TextButton(
onPressed: () {
setState(
() {
_bool = !_bool;
},
);
},
child: Text("Switch", style: TextStyle(color: Colors.white)),
),
],
),
body: Center(
child: AnimatedCrossFade(
// First widget
firstChild: Container(
height: 230,
width: 250,
color: Colors.blue,
),
// Second widget
secondChild: Container(
height: 250,
width: 230,
color: Colors.green,
),
// Parameter to change between two
// widgets on this basis of value of _bool
crossFadeState:
_bool ? CrossFadeState.showFirst : CrossFadeState.showSecond,
// Duration for crossFade animation.
duration: Duration(seconds: 1)),
),
);
}
}