SlideShare a Scribd company logo
1 of 13
How to Use IndexedStack Widget In Flutter?
The application is built by settling how the widgets interact with one
another. It suggests that the basis of your application is a widget.
Nearly everything in Flutter is a widget, including layout models. The
widgets are where you will find the images, icons, and text in a Flutter
application. The rows, columns, and grids that arrange, constrain, and
align the evident widgets are examples of non-visible extra widgets.
In this article, we will Explore IndexedStack Widget In Flutter.
Here is the constructor of the IndexStack widget.
IndexedStack(
{Key? key,
AlignmentGeometry alignment=AlignmentDirectional.topStart,
TextDirection? textDirection,
StackFit sizing = StackFit.loose,
int? index = 0,
List<widget> children = const <widget>[]}
)</widget></widget>
alignment: The non-positioned and partially-positioned children in the
stack are aligned using these attributes.
text direction: These properties are used to determine alignment
based on the text direction.
sizing: The non-positioned children in the stack are sized using these
properties.
index: These attributes are used to display the child’s index.
children: The List uses these properties.
An IndexedStack is a stack in which its index only allows for the display
of one component at a time.
a stack that displays a single child from a group of children. It is the
child with the specified index who is being shown.
How to construct a custom navigation bar in flutter is demonstrated in
the below demo. It demonstrates how a Flutter mobile application
development company will use the IndexedStack widget to create a
custom navigation bar.
Let’s see a full example of an IndexStack widget.
import 'package:flutter/material.dart';
void main() => runApp(const MaterialApp(home: IndexStackDemo()));
class IndexStackDemo extends StatefulWidget {
const IndexStackDemo({Key? key}) : super(key: key);
@override
_IndexStackDemoState createState() => _IndexStackDemoState();
}
class _IndexStackDemoState extends State<indexstackdemo> {
int index = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Indexed Stack Demo'),
),
body: Padding(
child: Column(
children: <widget>[_stackedContainers(), _navigationButtons()],
),
padding: const EdgeInsets.all(5.0),
),
);
}
Widget _stackedContainers() {
return Expanded(
child: IndexedStack(
index: index,
children: const <widget>[
Center(
child: Icon(
Icons.home,
size: 100,
),
),
Center(
child: Icon(
Icons.list,
size: 100,
),
),
Center(
child: Icon(
Icons.settings,
size: 100,
),
),
],
),
);
}
Widget _navigationButtons() {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <widget>[
ElevatedButton(
child: const Text(
'Home',
style: TextStyle(fontSize: 16.0, color: Colors.white),
),
onPressed: () {
setState(() {
index = 0;
});
},
),
ElevatedButton(
child: const Text(
'List',
style: TextStyle(fontSize: 16.0, color: Colors.white),
),
onPressed: () {
setState(() {
index = 1;
});
},
),
ElevatedButton(
child: const Text(
'Settings',
style: TextStyle(fontSize: 16.0, color: Colors.white),
),
onPressed: () {
setState(() {
index = 2;
});
},
),
],
);
}
}</widget></widget></widget></indexstackdemo>
Output:
Conclusion:
Today our Flutter experts has given a basic explanation of the
IndexedStack Widget’s fundamental structure in the article; you are
free to change the code as you see fit. This was a brief introduction
from my end to the IndexedStack Widget On User Interaction, which
utilizes Flutter to function.
Source: https://flutteragency.com/use-indexedstack-widget/

More Related Content

More from Flutter Agency

Hire Flutter Developers to Build Cross-Platform App Services - Stonesmentor
Hire Flutter Developers to Build Cross-Platform App Services - StonesmentorHire Flutter Developers to Build Cross-Platform App Services - Stonesmentor
Hire Flutter Developers to Build Cross-Platform App Services - StonesmentorFlutter Agency
 
A Guide For Recovering Your Failing App Project | Flutter Agency
A Guide For Recovering Your Failing App Project | Flutter AgencyA Guide For Recovering Your Failing App Project | Flutter Agency
A Guide For Recovering Your Failing App Project | Flutter AgencyFlutter Agency
 
Healthcare App-Development Company Fllutter Agency
Healthcare App-Development Company Fllutter AgencyHealthcare App-Development Company Fllutter Agency
Healthcare App-Development Company Fllutter AgencyFlutter Agency
 
Is Flutter Good for Web Development? | Flutter Agency
Is Flutter Good for Web Development? | Flutter AgencyIs Flutter Good for Web Development? | Flutter Agency
Is Flutter Good for Web Development? | Flutter AgencyFlutter Agency
 
Choosing App Development: Native, Hybrid, or Flutter Explained
Choosing App Development: Native, Hybrid, or Flutter ExplainedChoosing App Development: Native, Hybrid, or Flutter Explained
Choosing App Development: Native, Hybrid, or Flutter ExplainedFlutter Agency
 
The Role of Digital Transformation in Healthcare - Flutter Agency.pdf
The Role of Digital Transformation in Healthcare - Flutter Agency.pdfThe Role of Digital Transformation in Healthcare - Flutter Agency.pdf
The Role of Digital Transformation in Healthcare - Flutter Agency.pdfFlutter Agency
 
Why-Hire-Flutter-Developer-Flutter-Agency_.pdf
Why-Hire-Flutter-Developer-Flutter-Agency_.pdfWhy-Hire-Flutter-Developer-Flutter-Agency_.pdf
Why-Hire-Flutter-Developer-Flutter-Agency_.pdfFlutter Agency
 
Streamlining DNS Checks in Flutter Apps
Streamlining DNS Checks in Flutter AppsStreamlining DNS Checks in Flutter Apps
Streamlining DNS Checks in Flutter AppsFlutter Agency
 
Flutter UI/UX Design Tools: The Ultimate Guide for 2023
Flutter UI/UX Design Tools: The Ultimate Guide for 2023Flutter UI/UX Design Tools: The Ultimate Guide for 2023
Flutter UI/UX Design Tools: The Ultimate Guide for 2023Flutter Agency
 
Flutter Developer Skills to Master in 2024.pdf
Flutter Developer Skills to Master in 2024.pdfFlutter Developer Skills to Master in 2024.pdf
Flutter Developer Skills to Master in 2024.pdfFlutter Agency
 
Circular Timer in Flutter.pdf
Circular Timer in Flutter.pdfCircular Timer in Flutter.pdf
Circular Timer in Flutter.pdfFlutter Agency
 
flutteragency-com-handling-events-and-user-input-in-flutter-.pdf
flutteragency-com-handling-events-and-user-input-in-flutter-.pdfflutteragency-com-handling-events-and-user-input-in-flutter-.pdf
flutteragency-com-handling-events-and-user-input-in-flutter-.pdfFlutter Agency
 
Best Flutter Application Development Tools in 2022.pptx
Best Flutter Application Development Tools in 2022.pptxBest Flutter Application Development Tools in 2022.pptx
Best Flutter Application Development Tools in 2022.pptxFlutter Agency
 
What is Table Widget in Flutter.pptx
What is Table Widget in Flutter.pptxWhat is Table Widget in Flutter.pptx
What is Table Widget in Flutter.pptxFlutter Agency
 
HTML Parsing in FLUTTER for Android or iOS Development.pptx
HTML Parsing in FLUTTER for Android or iOS Development.pptxHTML Parsing in FLUTTER for Android or iOS Development.pptx
HTML Parsing in FLUTTER for Android or iOS Development.pptxFlutter Agency
 
What is SliverList Class in Flutter App Development.pptx
What is SliverList Class in Flutter App Development.pptxWhat is SliverList Class in Flutter App Development.pptx
What is SliverList Class in Flutter App Development.pptxFlutter Agency
 
How to use Listener Class in Flutter.pptx
How to use Listener Class in Flutter.pptxHow to use Listener Class in Flutter.pptx
How to use Listener Class in Flutter.pptxFlutter Agency
 
How to Vertically Center a Column in Flutter.pptx
How to Vertically Center a Column in Flutter.pptxHow to Vertically Center a Column in Flutter.pptx
How to Vertically Center a Column in Flutter.pptxFlutter Agency
 
How to Animate a Widget Across Screens in Flutter.pptx
How to Animate a Widget Across Screens in Flutter.pptxHow to Animate a Widget Across Screens in Flutter.pptx
How to Animate a Widget Across Screens in Flutter.pptxFlutter Agency
 
How to Build Doctors On Demand Mobile Application.pptx
How to Build Doctors On Demand Mobile Application.pptxHow to Build Doctors On Demand Mobile Application.pptx
How to Build Doctors On Demand Mobile Application.pptxFlutter Agency
 

More from Flutter Agency (20)

Hire Flutter Developers to Build Cross-Platform App Services - Stonesmentor
Hire Flutter Developers to Build Cross-Platform App Services - StonesmentorHire Flutter Developers to Build Cross-Platform App Services - Stonesmentor
Hire Flutter Developers to Build Cross-Platform App Services - Stonesmentor
 
A Guide For Recovering Your Failing App Project | Flutter Agency
A Guide For Recovering Your Failing App Project | Flutter AgencyA Guide For Recovering Your Failing App Project | Flutter Agency
A Guide For Recovering Your Failing App Project | Flutter Agency
 
Healthcare App-Development Company Fllutter Agency
Healthcare App-Development Company Fllutter AgencyHealthcare App-Development Company Fllutter Agency
Healthcare App-Development Company Fllutter Agency
 
Is Flutter Good for Web Development? | Flutter Agency
Is Flutter Good for Web Development? | Flutter AgencyIs Flutter Good for Web Development? | Flutter Agency
Is Flutter Good for Web Development? | Flutter Agency
 
Choosing App Development: Native, Hybrid, or Flutter Explained
Choosing App Development: Native, Hybrid, or Flutter ExplainedChoosing App Development: Native, Hybrid, or Flutter Explained
Choosing App Development: Native, Hybrid, or Flutter Explained
 
The Role of Digital Transformation in Healthcare - Flutter Agency.pdf
The Role of Digital Transformation in Healthcare - Flutter Agency.pdfThe Role of Digital Transformation in Healthcare - Flutter Agency.pdf
The Role of Digital Transformation in Healthcare - Flutter Agency.pdf
 
Why-Hire-Flutter-Developer-Flutter-Agency_.pdf
Why-Hire-Flutter-Developer-Flutter-Agency_.pdfWhy-Hire-Flutter-Developer-Flutter-Agency_.pdf
Why-Hire-Flutter-Developer-Flutter-Agency_.pdf
 
Streamlining DNS Checks in Flutter Apps
Streamlining DNS Checks in Flutter AppsStreamlining DNS Checks in Flutter Apps
Streamlining DNS Checks in Flutter Apps
 
Flutter UI/UX Design Tools: The Ultimate Guide for 2023
Flutter UI/UX Design Tools: The Ultimate Guide for 2023Flutter UI/UX Design Tools: The Ultimate Guide for 2023
Flutter UI/UX Design Tools: The Ultimate Guide for 2023
 
Flutter Developer Skills to Master in 2024.pdf
Flutter Developer Skills to Master in 2024.pdfFlutter Developer Skills to Master in 2024.pdf
Flutter Developer Skills to Master in 2024.pdf
 
Circular Timer in Flutter.pdf
Circular Timer in Flutter.pdfCircular Timer in Flutter.pdf
Circular Timer in Flutter.pdf
 
flutteragency-com-handling-events-and-user-input-in-flutter-.pdf
flutteragency-com-handling-events-and-user-input-in-flutter-.pdfflutteragency-com-handling-events-and-user-input-in-flutter-.pdf
flutteragency-com-handling-events-and-user-input-in-flutter-.pdf
 
Best Flutter Application Development Tools in 2022.pptx
Best Flutter Application Development Tools in 2022.pptxBest Flutter Application Development Tools in 2022.pptx
Best Flutter Application Development Tools in 2022.pptx
 
What is Table Widget in Flutter.pptx
What is Table Widget in Flutter.pptxWhat is Table Widget in Flutter.pptx
What is Table Widget in Flutter.pptx
 
HTML Parsing in FLUTTER for Android or iOS Development.pptx
HTML Parsing in FLUTTER for Android or iOS Development.pptxHTML Parsing in FLUTTER for Android or iOS Development.pptx
HTML Parsing in FLUTTER for Android or iOS Development.pptx
 
What is SliverList Class in Flutter App Development.pptx
What is SliverList Class in Flutter App Development.pptxWhat is SliverList Class in Flutter App Development.pptx
What is SliverList Class in Flutter App Development.pptx
 
How to use Listener Class in Flutter.pptx
How to use Listener Class in Flutter.pptxHow to use Listener Class in Flutter.pptx
How to use Listener Class in Flutter.pptx
 
How to Vertically Center a Column in Flutter.pptx
How to Vertically Center a Column in Flutter.pptxHow to Vertically Center a Column in Flutter.pptx
How to Vertically Center a Column in Flutter.pptx
 
How to Animate a Widget Across Screens in Flutter.pptx
How to Animate a Widget Across Screens in Flutter.pptxHow to Animate a Widget Across Screens in Flutter.pptx
How to Animate a Widget Across Screens in Flutter.pptx
 
How to Build Doctors On Demand Mobile Application.pptx
How to Build Doctors On Demand Mobile Application.pptxHow to Build Doctors On Demand Mobile Application.pptx
How to Build Doctors On Demand Mobile Application.pptx
 

How to Use IndexedStack Widget In Flutter.pptx

  • 1.
  • 2. How to Use IndexedStack Widget In Flutter? The application is built by settling how the widgets interact with one another. It suggests that the basis of your application is a widget. Nearly everything in Flutter is a widget, including layout models. The widgets are where you will find the images, icons, and text in a Flutter application. The rows, columns, and grids that arrange, constrain, and align the evident widgets are examples of non-visible extra widgets. In this article, we will Explore IndexedStack Widget In Flutter. Here is the constructor of the IndexStack widget.
  • 3. IndexedStack( {Key? key, AlignmentGeometry alignment=AlignmentDirectional.topStart, TextDirection? textDirection, StackFit sizing = StackFit.loose, int? index = 0, List<widget> children = const <widget>[]} )</widget></widget>
  • 4. alignment: The non-positioned and partially-positioned children in the stack are aligned using these attributes. text direction: These properties are used to determine alignment based on the text direction. sizing: The non-positioned children in the stack are sized using these properties. index: These attributes are used to display the child’s index. children: The List uses these properties.
  • 5. An IndexedStack is a stack in which its index only allows for the display of one component at a time. a stack that displays a single child from a group of children. It is the child with the specified index who is being shown. How to construct a custom navigation bar in flutter is demonstrated in the below demo. It demonstrates how a Flutter mobile application development company will use the IndexedStack widget to create a custom navigation bar. Let’s see a full example of an IndexStack widget.
  • 6. import 'package:flutter/material.dart'; void main() => runApp(const MaterialApp(home: IndexStackDemo())); class IndexStackDemo extends StatefulWidget { const IndexStackDemo({Key? key}) : super(key: key); @override _IndexStackDemoState createState() => _IndexStackDemoState(); } class _IndexStackDemoState extends State<indexstackdemo> { int index = 0; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Indexed Stack Demo'), ), body: Padding( child: Column( children: <widget>[_stackedContainers(), _navigationButtons()], ), padding: const EdgeInsets.all(5.0), ), ); }
  • 7. Widget _stackedContainers() { return Expanded( child: IndexedStack( index: index, children: const <widget>[ Center( child: Icon( Icons.home, size: 100, ), ),
  • 8. Center( child: Icon( Icons.list, size: 100, ), ), Center( child: Icon( Icons.settings, size: 100, ), ), ], ), ); }
  • 9. Widget _navigationButtons() { return Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: <widget>[ ElevatedButton( child: const Text( 'Home', style: TextStyle(fontSize: 16.0, color: Colors.white), ), onPressed: () { setState(() { index = 0; }); }, ),
  • 10. ElevatedButton( child: const Text( 'List', style: TextStyle(fontSize: 16.0, color: Colors.white), ), onPressed: () { setState(() { index = 1; }); }, ),
  • 11. ElevatedButton( child: const Text( 'Settings', style: TextStyle(fontSize: 16.0, color: Colors.white), ), onPressed: () { setState(() { index = 2; }); }, ), ], ); } }</widget></widget></widget></indexstackdemo>
  • 13. Conclusion: Today our Flutter experts has given a basic explanation of the IndexedStack Widget’s fundamental structure in the article; you are free to change the code as you see fit. This was a brief introduction from my end to the IndexedStack Widget On User Interaction, which utilizes Flutter to function. Source: https://flutteragency.com/use-indexedstack-widget/