BottomSheet Dynamic Theme GetX

import "package:flutter/material.dart";
import "package:get/get.dart";

void main()
{
runApp(MyApp());
}
class MyApp extends StatelessWidget
{
MyApp({super.key});

@override
Widget build(BuildContext context) {
return GetMaterialApp(
title: "BottomSheet and Dynamic Theme",
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.grey,
),
home: BottomDynamic(),
);
}
}
class BottomDynamic extends StatelessWidget
{
BottomDynamic({super.key});

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("BottomSheet and Dynamic Theme"),
centerTitle: true,
backgroundColor: Colors.grey,
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
ElevatedButton(
onPressed: (){
Get.bottomSheet(
Container(
child: Wrap(
children: <Widget>[
ListTile(
leading: const Icon(Icons.wb_sunny_outlined, color: Colors.white),
title: const Text("Light Theme", style: TextStyle(color: Colors.white),),
onTap: () {
Get.changeTheme(ThemeData.light());
},
),
ListTile(
leading: const Icon(Icons.wb_sunny, color: Colors.white),
title: const Text("Dark Theme", style: TextStyle(color: Colors.white),),
onTap: () {
Get.changeTheme(ThemeData.dark());
},
),
],
),
),
barrierColor: Colors.blue,
backgroundColor: Colors.brown,
/// When we don't want to close bottomSheet when we Tap outside(of bottomSheet)
/// in screen for that as shown below we can make isDismissible property false
/// By default, it is true
isDismissible: false,
shape: OutlineInputBorder(
borderRadius: BorderRadius.circular(11.0),
borderSide: BorderSide(
color: Colors.white,
width: 2,
),
),
///For Closing the Drag, we can make enableDrag property false
// enableDrag: false,
);
},
child: const Text("Show BottomSheet"),
),
],
),
),
);
}
}

Comments

Popular posts from this blog

Pagination with Bloc Pattern in Flutter

Pagination First Practical in Flutter

ExpansionPanel with ExpansionPanelList with Complete Collapse Operation in Flutter