ListWheel ScrollView Widget

 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 flutter",
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.purple,
),
home: const FlutterAnimate(),
);
}
}

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

@override
State<FlutterAnimate> createState() {
return AnimateState();
}
}

class AnimateState extends State<FlutterAnimate> {
var arrIndex = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];

/*here "1","2","3"... is the array values*/

@override
Widget build(BuildContext context) {
return Scaffold(
drawer: const Drawer(),
appBar: AppBar(
title: const Text(
"Flutter ListWheel ScrollView",
style: TextStyle(fontWeight: FontWeight.bold),
),
centerTitle: true,
backgroundColor: Colors.grey,
),
body: Center(
child: ListWheelScrollView(
itemExtent: 200,
children: arrIndex.map(
(value) {
/*Here,"(value)" will get from above array named "arrIndex"*/

return Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Colors.blue.shade300,
Colors.blue.shade100,
],
),
color: Colors.blue,
/*color can directly apply through BoxDecoration from decoration*/
borderRadius: BorderRadius.circular(21),
),
width: double.infinity,
child: Center(
child: Text(
"$value",
/*Here,obtained integer values from above array "arrIndex"
will convert into string in "$value"*/
style: const TextStyle(
fontSize: 70,
color: Colors.white,
),
),
),
//color: Colors.blue,
),
);
},
).toList(), /*Here,converting in the List format*/

/*[
Container(
width: 200,
color: Colors.blue,
),
Container(
width: 200,
color: Colors.blue,
),
Container(
width: 200,
color: Colors.blue,
),
Container(
width: 200,
color: Colors.blue,
),
Container(
width: 200,
color: Colors.blue,
),
Container(
width: 200,
color: Colors.blue,
),
Container(
width: 200,
color: Colors.blue,
),
Container(
width: 200,
color: Colors.blue,
),
],*/
),
),
);
}
}

Comments

Popular posts from this blog

Second GET API Calling with Bloc simple Example in Flutter

Stack Container Scrollable Card widget UI with Custom Widget

Pagination with Bloc Pattern in Flutter