frosted_glass_effect 0.0.2 frosted_glass_effect: ^0.0.2 copied to clipboard
This package gives a frosted glassy effect to the widgets, images and simple containers.
import 'package:flutter/material.dart';
import 'package:frosted_glass_effect/frosted_glass_effect.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.blue,
appBar: AppBar(
backgroundColor: Colors.white,
title: Text(widget.title),
),
body: Center(
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
//////////////////////////////////// Example with the Background Color /////////////////////////////////////////
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: [
Expanded(
child: GlassContainer(
radius: 20,
backgroundColor: Colors.red,
widget: Padding(
padding: const EdgeInsets.all(20.0),
child: Container(
child: const Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
"\$16/mo",
style: TextStyle(
color: Colors.white,
fontSize: 30,
fontWeight: FontWeight.bold),
),
Spacer(),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Spacer(),
Column(
crossAxisAlignment:
CrossAxisAlignment.end,
children: [
Text(
"PRO",
style: TextStyle(
color: Colors.white,
fontSize: 30,
fontWeight: FontWeight.normal),
),
Text(
"On Sale Now!",
style: TextStyle(
color: Colors.white,
fontSize: 30,
fontWeight: FontWeight.bold),
)
],
)
],
)
],
),
),
),
),
),
],
),
),
//////////////////////////////////// Example with the Background Color /////////////////////////////////////////
//////////////////////////////////// Restricting Glass Container width with Container /////////////////////////////////////////
SizedBox(
width: 300,
child: GlassContainer(
// image: "assets/bg.jpg",
backgroundColor: Colors.red,
widget: Padding(
padding: const EdgeInsets.all(20.0),
child: Container(
height: 200,
// width: 200,
child: const Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
"\$16/mo",
style: TextStyle(
color: Colors.white,
fontSize: 30,
fontWeight: FontWeight.bold),
),
Spacer(),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Spacer(),
Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
"PRO",
style: TextStyle(
color: Colors.white,
fontSize: 30,
fontWeight: FontWeight.normal),
),
Text(
"On Sale Now!",
style: TextStyle(
color: Colors.white,
fontSize: 30,
fontWeight: FontWeight.bold),
)
],
)
],
)
],
),
),
),
radius: 20,
),
),
const SizedBox(
height: 20,
),
//////////////////////////////////// Example with the Background Image /////////////////////////////////////////
const GlassContainer(
backgroundImage: "assets/bg.jpg",
widget: Text("Image"),
)
//////////////////////////////////// Example with the Background Image /////////////////////////////////////////
],
),
),
),
);
}
}