I have an application like this:
The purpose of the application is to show the spelling of the numbers in the list. Numbers and their spelling are in a list. List:
List<wordAndMeaning> wordsList = [
wordAndMeaning("1", "One", false),
wordAndMeaning("2", "Two", false),
wordAndMeaning("3", "Three", false),
wordAndMeaning("4", "Four", false),
wordAndMeaning("5", "Five", false),
wordAndMeaning("6", "Six", false),
wordAndMeaning("7", "Seven", false),
wordAndMeaning("8", "Eight", false),
wordAndMeaning("9", "Nine", false),
wordAndMeaning("10", "Ten", false),
wordAndMeaning("11", "Eleven", false),
wordAndMeaning("12", "Twelve", false),
wordAndMeaning("13", "Thirteen", false),
wordAndMeaning("14", "Fourteen", false),
wordAndMeaning("15", "Fifteen", false),
wordAndMeaning("16", "Sixteen", false),
wordAndMeaning("17", "Seventeen", false),
wordAndMeaning("18", "Eighteen", false),
wordAndMeaning("19", "Nineteen", false),
wordAndMeaning("20", "Twenty", false),
For each list item, that is, for each number, there is 1 scrolling screen. The number 1 on the first screen, the number 2 on the second screen, the number 3 on the third screen, and so on, up to 20. I took the screen of the first 3 numbers as a photo.
Let's get to the real problem. I want to make the system of showing the spelling of this number from 1 to 20. As such, there will be 30 scrolling screens. This will be very inefficient and there will be too many scrolling screens.
As a solution to this problem, I thought of showing 5 numbers on each page. In other words, there will be a total of 4 scrolling screens and it will show the writing of 5 numbers on each page. For example, the first screen will look like this:
1: One
2: Two
3: Three
4: Four
5: Five
Of course, these numbers will appear as a list and each number will have an eye icon. I want the list to show the spelling of the 3rd number when I press the eye icon of the 3rd number.
How can I do this system I described?
Here is my code that creates a custom scrolling screen for each number:
import 'package:flutter/material.dart';
import 'package:carousel_slider/carousel_slider.dart';
import 'package:getwidget/getwidget.dart';
class sayilarLearn_1 extends StatefulWidget {
@override
State<sayilarLearn_1> createState() => _sayilarLearn_1State();
}
class _sayilarLearn_1State extends State<sayilarLearn_1> {
final CarouselController _controller = CarouselController();
List<wordAndMeaning> wordsList = [
wordAndMeaning("1", "One", false),
wordAndMeaning("2", "Two", false),
wordAndMeaning("3", "Three", false),
wordAndMeaning("4", "Four", false),
wordAndMeaning("5", "Five", false),
wordAndMeaning("6", "Six", false),
wordAndMeaning("7", "Seven", false),
wordAndMeaning("8", "Eight", false),
wordAndMeaning("9", "Nine", false),
wordAndMeaning("10", "Ten", false),
wordAndMeaning("11", "Eleven", false),
wordAndMeaning("12", "Twelve", false),
wordAndMeaning("13", "Thirteen", false),
wordAndMeaning("14", "Fourteen", false),
wordAndMeaning("15", "Fifteen", false),
wordAndMeaning("16", "Sixteen", false),
wordAndMeaning("17", "Seventeen", false),
wordAndMeaning("18", "Eighteen", false),
wordAndMeaning("19", "Nineteen", false),
wordAndMeaning("20", "Twenty", false),
];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.amber[500],
bottomOpacity: 0,
leading: IconButton(
icon: Icon(Icons.arrow_back_ios),
onPressed: () {
Navigator.pop(context);
},
),
title: Text("Numbers", style: TextStyle(fontSize: 25),),
),
backgroundColor: Colors.amber,
body: Builder(builder: (context) {
final double height = MediaQuery.of(context).size.height - 160;
return Column(
children: [
CarouselSlider(
carouselController: _controller,
options: CarouselOptions(
height: height,
viewportFraction: 1.0,
enlargeCenterPage: true,
),
items: wordsList.map((wordAndMeaning word) { // <<<<<<<<<!!!!!
return Builder(
builder: (BuildContext context) {
return Container(
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(color: Colors.amber),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
if (word.showMeaning) ...[
Text(word.meaning,
style: TextStyle(
fontSize: 35, color: Colors.white)),
Text(word.word,
style:
TextStyle(fontSize: 20, color: Colors.white)),
],
if (!word.showMeaning) ...[
Text(word.word,
style: TextStyle(
fontSize: 35, color: Colors.white)),
],
],
),
),
const SizedBox(
width: 10,
),
IconButton(
icon: Icon(Icons.remove_red_eye_sharp),
color: Colors.white,
iconSize: 25,
onPressed: () {
setState(() {
word.showMeaning = !word.showMeaning;
});
},
),
],
),
);
},
);
}).toList(),
),
Container(
padding: EdgeInsets.all(5),
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20),
topRight: Radius.circular(20)),
),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
),
width: 55,
height: 55,
child: RaisedButton(
color: Colors.blue,
child: Icon(Icons.arrow_back_ios, size: 30, color: Colors.white,),
onPressed: () {
_controller.previousPage(
duration: const Duration(milliseconds: 100),
curve: Curves.easeInCirc,
);
},
// köşeyi yuvarlaştırma:
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(25),
),
)
),
SizedBox(
width: 10,
),
SizedBox(
width: 10,
),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
),
width: 55,
height: 55,
child: Container(
child: RaisedButton(
color: Colors.blue,
child: Icon(Icons.arrow_forward_ios, size: 30, color: Colors.white,),
onPressed: () {
_controller.nextPage(
duration: const Duration(milliseconds: 100),
curve: Curves.easeInCirc,
);
},
// köşeyi yuvarlaştırma:
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(25),
),
)
),
),
],
),
],
),
)
],
);
}),
);
}
}
Thanks in advance for the help.



