Gradient

 import "package:flutter/material.dart";


void main() {
runApp(const MyApp());
}

class MyApp extends StatelessWidget {
const MyApp({super.key});

@override
Widget build(BuildContext context) {
return MaterialApp(
title: "hello",
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.teal,
),
home: const FlutterGradient(),
);
}
}

class FlutterGradient extends StatefulWidget {
const FlutterGradient({super.key});

@override
State<FlutterGradient> createState() {
return GradientState();
}
}

class GradientState extends State<FlutterGradient> {
var grad = TextEditingController();

@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
FocusManager.instance.primaryFocus?.unfocus();
},
child: Scaffold(
drawer: const Drawer(),
appBar: AppBar(
title: const Text(
"Flutter Gradient",
style: TextStyle(fontWeight: FontWeight.bold),
),
centerTitle: true,
backgroundColor: Colors.grey,
),
body: Container(
/*decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Colors.orange.shade200,
Colors.purple.shade200,
Colors.brown.shade200,
//here,"ff" denotes the transparency of color."ff" this two values differentiate that given color is transparent or
//opaque."d4fc79" denotes the hex code of color,hex code is between 0 to 15(0 to 9 & then a to f)
//Color(0xffd4fc79), Color(0xff96e6a1),
//Color(0x88fbc2eb), Color(0x99a6c1ee),
//Color(0xfffbc2eb), Color(0xffa6c1ee),
//Color(0xfff6d365), Color(0xfffda085),
const Color(0xffff9a9e), const Color(0xfffecfef), const Color(0xffff9b7e),
//Color(0xffcfd9df), Color(0xffe2ebf0),
//Color(0xfffad0c4), Color(0xffffd1ff),
//Color(0x9efad0c4), Color(0x9effd1ff),
],
//below is color combination position as per our requirement or starting & ending state at desired position
//by indicating coordinates of x and y
begin: const FractionalOffset(1.0,0.5),
end: const FractionalOffset(0.0,0.5),
stops: const [0.0, 0.5, 1.0], //colors will stop after limits indicated in "stops"
//stops: [0.0, 0.2, 1.0],
),
),*/

decoration: const BoxDecoration(
gradient: RadialGradient(
colors: [
Color(0xffffecd2),
Color(0xfffcb69f),
],
//center: Alignment.topLeft,
center: Alignment.bottomCenter,
stops: [0.0, 1.0],
),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.all(20.0),
child: TextField(
decoration: const InputDecoration(
label: Text("Enter the value..."),
),
controller: grad,
),
),
ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blue,
),
onPressed: () {
String show = grad.text;
showDialog(
context: context,
builder: (context) {
return AlertDialog(
content: Text(grad.text),
title: Text(grad.text),

/* shape: OutlineInputBorder(
//borderRadius: BorderRadius.all(Radius.elliptical(2,4),)
//borderRadius: BorderRadius.zero,
),*/
);
});
print("value is : $show");
},
child: const Text(
"show",
style: TextStyle(
fontWeight: FontWeight.bold, color: Colors.white),
),
),
],
),
),
),
);
}
}

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