how to locate ListWheelScrollView to a given index? - flutter

I want to locate the ListWheelScrollView to a randomly given index.
While locating, animation of spin must work as well.
How can I locate to a given index?
Edit: It will be like a slot machine.

You can copy paste run full code below
You can use FixedExtentScrollController and call animateToItem
code snippet
final FixedExtentScrollController _controller = FixedExtentScrollController();
...
body: Center(
child: ListWheelScrollView(
controller: _controller,
itemExtent: 80,
magnification: 1.2,
useMagnifier: true,
physics: FixedExtentScrollPhysics(),
children: listtiles, //List of widgets
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
_controller.animateToItem(random.nextInt(10),
duration: Duration(milliseconds: 500), curve: Curves.linear);
},
child: Icon(Icons.add),
backgroundColor: Colors.green,
),
working demo
full code
import 'package:flutter/material.dart';
import 'dart:math';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
#override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final FixedExtentScrollController _controller = FixedExtentScrollController();
Random random = Random();
List<Widget> listtiles = [
GestureDetector(
onTap: () {
print("clicked 1");
},
child: ListTile(
leading: Icon(Icons.portrait),
title: Text("Portrait"),
subtitle: Text("Beautiful View..!"),
trailing: Icon(Icons.arrow_forward_ios),
),
),
GestureDetector(
onTap: () {
print("clicked 2");
},
child: ListTile(
leading: Icon(Icons.landscape),
title: Text("LandScape"),
subtitle: Text("Beautiful View..!"),
trailing: Icon(Icons.remove),
),
),
GestureDetector(
onTap: () {
print("clicked 3");
},
child: ListTile(
leading: Icon(Icons.map),
title: Text("Map"),
subtitle: Text("Map View..!"),
trailing: Icon(Icons.wb_sunny),
),
),
ListTile(
leading: Icon(Icons.landscape),
title: Text("LandScape"),
subtitle: Text("Wonderful View..!"),
trailing: Icon(Icons.wb_sunny),
),
ListTile(
leading: Icon(Icons.list),
title: Text("List Example"),
subtitle: Text("List Wheel Scroll view .!"),
trailing: Icon(Icons.cloud),
),
ListTile(
leading: Icon(Icons.settings),
title: Text("Settings"),
subtitle: Text("Change the setting..!"),
trailing: Icon(Icons.portrait),
),
ListTile(
leading: Icon(Icons.event),
title: Text("Add data"),
subtitle: Text("Data View..!"),
trailing: Icon(Icons.add),
),
ListTile(
leading: Icon(Icons.landscape),
title: Text("LandScape"),
subtitle: Text("Beautiful View..!"),
trailing: Icon(Icons.wb_sunny),
),
ListTile(
leading: Icon(Icons.email),
title: Text("Email"),
subtitle: Text("Check Email..!"),
trailing: Icon(Icons.arrow_forward),
),
ListTile(
leading: Icon(Icons.games),
title: Text("Games"),
subtitle: Text("Play Games..!"),
trailing: Icon(Icons.zoom_out_map),
),
];
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("ListView ScrollView Wheel"),
),
body: Center(
child: ListWheelScrollView(
controller: _controller,
itemExtent: 80,
magnification: 1.2,
useMagnifier: true,
physics: FixedExtentScrollPhysics(),
children: listtiles, //List of widgets
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
_controller.animateToItem(random.nextInt(10),
duration: Duration(milliseconds: 500), curve: Curves.linear);
},
child: Icon(Icons.add),
backgroundColor: Colors.green,
),
);
}
}

Related

children above title in ExpansionTile flutter

I need to place the title of expansion tile in the bottom on expanding
this is my code:
ExpansionTile(
title: Text('Colors'),
subtitle: Text('Expand this tile to see its contents'),
// Contents
children: [
ListTile(
leading: CircleAvatar(
backgroundColor: Colors.blue,
),
title: Text('Blue')),
ListTile(
leading: CircleAvatar(
backgroundColor: Colors.red,
),
title: Text('Red')),
ListTile(
leading: CircleAvatar(
backgroundColor: Colors.amber,
),
title: Text('Amber')),
ListTile(
leading: CircleAvatar(
backgroundColor: Colors.pink,
),
title: Text('Pink')),
ListTile(
leading: CircleAvatar(
backgroundColor: Colors.green,
),
title: Text('Green')),
],
),
and this is the result
and this is what im trying to do
That's just not how the expansion tile was designed. :-)
But you can make your own Expansion Tile.
Just as an example, I kinda misused the ExpansionTile widget. You can do it more elegantly by completely designing it withput using ExpansionTile within, but at least it shows how you can do it quite quickly.
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(
child: UpsideDownExpansionTile(),
),
),
);
}
}
class UpsideDownExpansionTile extends StatefulWidget {
#override
createState() => _UpsideDownExpansionTileState();
}
class _UpsideDownExpansionTileState extends State<UpsideDownExpansionTile> {
bool expanded = false;
#override
Widget build(BuildContext context) {
return Column(children: [
if (expanded) ...[
ListTile(
leading: CircleAvatar(
backgroundColor: Colors.blue,
),
title: Text('Blue')),
ListTile(
leading: CircleAvatar(
backgroundColor: Colors.red,
),
title: Text('Red')),
ListTile(
leading: CircleAvatar(
backgroundColor: Colors.amber,
),
title: Text('Amber')),
ListTile(
leading: CircleAvatar(
backgroundColor: Colors.pink,
),
title: Text('Pink')),
ListTile(
leading: CircleAvatar(
backgroundColor: Colors.green,
),
title: Text('Green')),
],
ExpansionTile(
title: Text('Colors'),
subtitle: Text('Expand this tile to see its contents'),
onExpansionChanged: (newExpanded) {
setState(() {
expanded = newExpanded;
});
},
// Contents
children: [],
)
]);
}
}
Explanation: The ExpansionTile is just there for the little arrow widget on the right side. It triggers a function on every change. Within this function we set expanded to true or false. And according to this variable, the ListTiles with the colors are either shown or not.

Flutter - Multi Page Navigation using bottom navigation bar icons

I'm trying to navigate to different pages within my app using the icons in my bottom navigation bar. I have tried many tutorials and can't seem to work out the best way to achieve this. I have created my Homepage (code below) and 2 additional pages, Inbox and Signin, both return simple scaffolds.
Firstly i'm interested to know if this is the best way to do what i'm trying to achieve and second, how can my code be altered to allow me to navigate to different pages depending on which icon is tapped. I'm aware that the code below doesn't execute, i'm just trying to show what i've tried.
My code:
class HomePage extends StatefulWidget {
#override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
_onTap(int index) {
Navigator.of(context)
.push(MaterialPageRoute<Null>(builder: (BuildContext context) {
return _children[_currentIndex];
}));}
final List<Widget> _children = [
HomePage(),
InboxPage(),
SignInPage()
];
int _currentIndex = 0;
#override
Widget build(BuildContext context) {
SizeConfig().init(context);
return Scaffold(
appBar: PreferredSize(preferredSize: Size(double.infinity, 75),
child: AppBar(
elevation: 0.0,
centerTitle: false,
title: Column(
children: <Widget>[
Align(
alignment: Alignment.centerLeft,
child: Text(
currentDate,
textAlign: TextAlign.left,
style: TextStyle(
color: titleTextColor,
fontWeight: subTitleFontWeight,
fontFamily: titleFontFamily,
fontSize: subTitleFontSize),
),
),
SizedBox(
height: 15,
),
Align(
alignment: Alignment.centerLeft,
child: Text(
'Some text here',
style: TextStyle(
color: titleTextColor,
fontWeight: titleTextFontWeight,
fontFamily: titleFontFamily,
fontSize: titleFontSize),
),
),
],
),
backgroundColor: kPrimaryColor,
shape: titleBarRounding
),
),
body: BodyOne(),
bottomNavigationBar: BottomNavigationBar(
currentIndex: _currentIndex,
type: BottomNavigationBarType.fixed,
items: [
BottomNavigationBarItem(
icon: Icon(Icons.home),
title: Text('Home'),
),
BottomNavigationBarItem(
icon: Icon(Icons.mail),
title: Text('Inbox'),
),
BottomNavigationBarItem(
icon: Icon(Icons.account_circle),
title: Text('Account'),
)
],
onTap: () => _onTap(_currentIndex),
),);
}
}
Thanks in advance.
The screen you are in can't be part of the Screens you're navigating to and you don't need to push a new screen each time you just have to change selectedPage, this is an example of how it should look:
import 'package:flutter/material.dart';
class HomePage extends StatefulWidget {
#override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
int selectedPage = 0;
final _pageOptions = [
HomeScreen(),
InboxScreen(),
SignInScreen()
];
#override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
body: _pageOptions[selectedPage],
bottomNavigationBar: BottomNavigationBar(
items: [
BottomNavigationBarItem(icon: Icon(Icons.home, size: 30), title: Text('Home')),
BottomNavigationBarItem(icon: Icon(Icons.mail, size: 30), title: Text('Inbox')),
BottomNavigationBarItem(icon: Icon(Icons.account_circle, size: 30), title: Text('Account')),
],
selectedItemColor: Colors.green,
elevation: 5.0,
unselectedItemColor: Colors.green[900],
currentIndex: selectedPage,
backgroundColor: Colors.white,
onTap: (index){
setState(() {
selectedPage = index;
});
},
)
);
}
}
Let me know if you need more explanation.
The input parameter of the _onTap function is unused and needs to be deleted.
_onTap() {
Navigator.of(context)
.push(MaterialPageRoute(builder: (BuildContext context) => _children[_currentIndex])); // this has changed
}
In the onTap of the BottomNavigationBar you need to change the _currentIndex and then call the _onTap function which navigates to the selected screen.
onTap: (index) {
setState(() {
_currentIndex = index;
});
_onTap();
},
You can add this BottomNavigationBar to all of the screens, but pay attention to the initial value of the _currentIndex that changes according to the screen you're putting the BottomNavigationBar in.
Full code:
_onTap() { // this has changed
Navigator.of(context)
.push(MaterialPageRoute(builder: (BuildContext context) => _children[_currentIndex])); // this has changed
}
final List<Widget> _children = [
HomePage(),
InboxPage(),
SignInPage()
];
#override
Widget build(BuildContext context) {
SizeConfig().init(context);
return Scaffold(
appBar: PreferredSize(
preferredSize: Size(double.infinity, 75),
child: AppBar(
elevation: 0.0,
centerTitle: false,
title: Column(
children: <Widget>[
Align(
alignment: Alignment.centerLeft,
child: Text(
currentDate,
textAlign: TextAlign.left,
style: TextStyle(
color: titleTextColor,
fontWeight: subTitleFontWeight,
fontFamily: titleFontFamily,
fontSize: subTitleFontSize),
),
),
SizedBox(
height: 15,
),
Align(
alignment: Alignment.centerLeft,
child: Text(
'Some text here',
style: TextStyle(
color: titleTextColor,
fontWeight: titleTextFontWeight,
fontFamily: titleFontFamily,
fontSize: titleFontSize),
),
),
],
),
backgroundColor: kPrimaryColor,
shape: titleBarRounding
),
),
body: BodyOne(),
body: Container(),
bottomNavigationBar: BottomNavigationBar(
currentIndex: _currentIndex,
type: BottomNavigationBarType.fixed,
items: [
BottomNavigationBarItem(
icon: Icon(Icons.home),
title: Text('Home'),
),
BottomNavigationBarItem(
icon: Icon(Icons.mail),
title: Text('Inbox'),
),
BottomNavigationBarItem(
icon: Icon(Icons.account_circle),
title: Text('Account'),
)
],
onTap: (index) { // this has changed
setState(() {
_currentIndex = index;
});
_onTap();
},
),
);
}
The best way to do it is creating a wrapper to your screens. Like this:
class Wrapper extends StatefulWidget {
Wrapper();
_WrapperState createState() => _WrapperState();
}
class _WrapperState extends State<Wrapper> {
int _currentIndex = 0;
final List<Widget> _children = [
HomePage(),
InboxPage(),
SignInPage()
];
void onTabTapped(int index) {
setState(() {
_currentIndex = index;
});
}
#override
Widget build(BuildContext context) {
return Scaffold(
body: _children[_currentIndex],
bottomNavigationBar: BottomNavigationBar(
onTap: onTabTapped,
currentIndex: _currentIndex,
items:[
BottomNavigationBarItem(
icon: Icon(Icons.home),
title: Text('Home'),
),
BottomNavigationBarItem(
icon: Icon(Icons.mail),
title: Text('Inbox'),
),
BottomNavigationBarItem(
icon: Icon(Icons.account_circle),
title: Text('Account'),
)
],
),
);
}
}

How to dynamically change icons in flutter gridtile cards once triggered on tap

Im pretty new to fultter and im trying to make a grid that has tappable cards. I want to choose what to plant and have the icon change as well the information from that plant to saved to that individual gridtile. I was wondering how do you set a new state for a specific gridtile once it is triggered? I attached the code below. I cant seem to get the icon on the gridtile to change from the shovel icon to the sprout icon using the stateful widget.
import 'package:flutter/material.dart';
import 'my_flutter_app_icons.dart';
class WindowSillGrid extends StatefulWidget {
#override
_WindowSillGridState createState() => _WindowSillGridState();
}
class _WindowSillGridState extends State<WindowSillGrid> {
#override
Widget build(BuildContext context) {
final title = "Window Sill Grid";
return MaterialApp(
title: title,
home: Scaffold(
backgroundColor: Colors.brown[400],
appBar: AppBar(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(
bottom: Radius.circular(20))),
centerTitle: true,
backgroundColor: Colors.green[600],
title: Text(title),
),
body: GridView.count(
childAspectRatio: 1.0,
crossAxisCount: 2,
children: List.generate(6, (index) {
return Center(
child: ChoiceCard(choice: PlantGrowth[index]),
);
}))));
}
}
class PlantGrowthIcons {
const PlantGrowthIcons({this.title, this.icon});
final String title;
final IconData icon;
}
const List<PlantGrowthIcons> PlantGrowth = const <PlantGrowthIcons>[
const PlantGrowthIcons(title: 'Add Plant', icon: MyFlutterApp.shovel),
const PlantGrowthIcons(title: 'Add Plant', icon: MyFlutterApp.shovel),
const PlantGrowthIcons(title: 'Add Plant', icon: MyFlutterApp.shovel),
const PlantGrowthIcons(title: 'Add Plant', icon: MyFlutterApp.shovel),
const PlantGrowthIcons(title: 'Add Plant', icon: MyFlutterApp.shovel),
const PlantGrowthIcons(title: 'Add Plant', icon: MyFlutterApp.shovel),
];
class ChoiceCard extends StatelessWidget {
const ChoiceCard({Key key, this.choice}) : super(key: key);
final PlantGrowthIcons choice;
#override
Widget build(BuildContext context) {
return InkWell(
onTap: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) => WindowSillGridEditPage()));},
child: Container(
color: Colors.brown[300],
child: GridTile(
child: Card(
color: Colors.brown[400],
child: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Icon(choice.icon, size: 80.0, color: Colors.white),
Text(choice.title, style: TextStyle(color: Colors.white),),
],
),
),
),
),
),
);
}
}
const List<Widget> items = const[
ListTile(
leading: Icon(MyFlutterApp.sprout, size: 50),
title: Text('Asparagus'),
subtitle: Text('Description here'),
),
ListTile(
leading: Icon(MyFlutterApp.sprout, size: 50),
title: Text('Egg Plant'),
subtitle: Text('Description here')
),
ListTile(
leading: Icon(MyFlutterApp.sprout, size: 50),
title: Text('Tomato'),
subtitle: Text('Description here'),
),
ListTile(
leading: Icon(MyFlutterApp.sprout, size: 50),
title: Text('Cucumber'),
subtitle: Text('Description here'),
),
class WindowSillGridEditPage extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
backgroundColor: Colors.green[600],
title: Text('Plant3r'),
),
body: Container(
child:
ListView(
itemExtent: 60,
children: items,
),
),
);}
}
You can copy paste run full code below
You can in ChoiceCard pass index and refresh callback
And set PlantGrowth[widget.index].icon = MdiIcons.sprout; with InkWell
code snippet
ChoiceCard(
choice: PlantGrowth[index],
index: index,
callback: refresh),
...
return InkWell(
onTap: () async {
await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => WindowSillGridEditPage(index: index)));
callback();
...
#override
initState() {
items = [
InkWell(
onTap: () {
PlantGrowth[widget.index].title = "Asparagus";
PlantGrowth[widget.index].icon = MdiIcons.sprout;
},
child: ListTile(
leading: Icon(MdiIcons.sprout, size: 50),
title: Text('Asparagus'),
subtitle: Text('Description here'),
),
),
working demo
full code
import 'package:flutter/material.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
class WindowSillGrid extends StatefulWidget {
#override
_WindowSillGridState createState() => _WindowSillGridState();
}
class _WindowSillGridState extends State<WindowSillGrid> {
void refresh() {
setState(() {});
}
#override
Widget build(BuildContext context) {
final title = "Window Sill Grid";
return MaterialApp(
title: title,
home: Scaffold(
backgroundColor: Colors.brown[400],
appBar: AppBar(
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.vertical(bottom: Radius.circular(20))),
centerTitle: true,
backgroundColor: Colors.green[600],
title: Text(title),
),
body: GridView.count(
childAspectRatio: 1.0,
crossAxisCount: 2,
children: List.generate(6, (index) {
return Center(
child: ChoiceCard(
choice: PlantGrowth[index],
index: index,
callback: refresh),
);
}))));
}
}
class PlantGrowthIcons {
PlantGrowthIcons({this.title, this.icon});
String title;
IconData icon;
}
List<PlantGrowthIcons> PlantGrowth = <PlantGrowthIcons>[
PlantGrowthIcons(title: 'Add Plant', icon: MdiIcons.shovel),
PlantGrowthIcons(title: 'Add Plant', icon: MdiIcons.shovel),
PlantGrowthIcons(title: 'Add Plant', icon: MdiIcons.shovel),
PlantGrowthIcons(title: 'Add Plant', icon: MdiIcons.shovel),
PlantGrowthIcons(title: 'Add Plant', icon: MdiIcons.shovel),
PlantGrowthIcons(title: 'Add Plant', icon: MdiIcons.shovel),
];
class ChoiceCard extends StatelessWidget {
ChoiceCard({Key key, this.choice, this.index, this.callback})
: super(key: key);
PlantGrowthIcons choice;
final int index;
final VoidCallback callback;
#override
Widget build(BuildContext context) {
return InkWell(
onTap: () async {
await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => WindowSillGridEditPage(index: index)));
callback();
},
child: Container(
color: Colors.brown[300],
child: GridTile(
child: Card(
color: Colors.brown[400],
child: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Icon(choice.icon, size: 80.0, color: Colors.white),
Text(
choice.title,
style: TextStyle(color: Colors.white),
),
],
),
),
),
),
),
);
}
}
class WindowSillGridEditPage extends StatefulWidget {
final int index;
WindowSillGridEditPage({this.index});
#override
_WindowSillGridEditPageState createState() => _WindowSillGridEditPageState();
}
class _WindowSillGridEditPageState extends State<WindowSillGridEditPage> {
List<Widget> items;
#override
initState() {
items = [
InkWell(
onTap: () {
PlantGrowth[widget.index].title = "Asparagus";
PlantGrowth[widget.index].icon = MdiIcons.sprout;
},
child: ListTile(
leading: Icon(MdiIcons.sprout, size: 50),
title: Text('Asparagus'),
subtitle: Text('Description here'),
),
),
InkWell(
onTap: () {
PlantGrowth[widget.index].title = "Egg Plant";
PlantGrowth[widget.index].icon = MdiIcons.sprout;
},
child: ListTile(
leading: Icon(MdiIcons.sprout, size: 50),
title: Text('Egg Plant'),
subtitle: Text('Description here')),
),
InkWell(
onTap: () {
PlantGrowth[widget.index].title = "Tomato";
PlantGrowth[widget.index].icon = MdiIcons.sprout;
},
child: ListTile(
leading: Icon(MdiIcons.sprout, size: 50),
title: Text('Tomato'),
subtitle: Text('Description here'),
),
),
InkWell(
onTap: () {
PlantGrowth[widget.index].title = "Cucumber";
PlantGrowth[widget.index].icon = MdiIcons.sprout;
},
child: ListTile(
leading: Icon(MdiIcons.sprout, size: 50),
title: Text('Cucumber'),
subtitle: Text('Description here'),
),
),
];
}
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
backgroundColor: Colors.green[600],
title: Text('Plant3r'),
),
body: Container(
child: ListView(
itemExtent: 60,
children: items,
),
),
);
}
}
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: WindowSillGrid(),
);
}
}

How to change the ToolBar Color for the Navigation Drawer

How can I change the toolbar color for the Navigation drawer.
Just add padding: EdgeInsets.all(0.0), in your listview widget inside Drawer widget
Try this
class HomePage extends StatefulWidget {
#override
_HomePageScreen createState() => _HomePageScreen();
}
class _HomePageScreen extends State<HomePage> {
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Home"),
),
drawer: Drawer(
child: ListView(
padding: EdgeInsets.all(0.0),
children: <Widget>[
UserAccountsDrawerHeader(
accountName: Text("Nilesh Rathod"),
accountEmail: Text("nilesh#gmail.com"),
currentAccountPicture: CircleAvatar(
backgroundColor: Colors.white,
child: Text("Nilu"),
),
),
ListTile(
title: Text("Home"),
trailing: Icon(Icons.new_releases),
),
Divider(),
ListTile(
title: Text("Profile"),
trailing: Icon(Icons.person),
onTap: () => {},
),
Divider(),
ListTile(
title: Text("Tab Layout"),
trailing: Icon(Icons.person),
onTap: () => {},
),
Divider(),
ListTile(
title: Text("Comman View Demo"),
trailing: Icon(Icons.person),
onTap: () => {},
),
Divider(),
ListTile(
title: Text("Close"),
trailing: Icon(Icons.close),
onTap: () => Navigator.of(context).pop(),
),
],
),
),
body: CachedNetworkImage(
imageUrl: 'https://i.stack.imgur.com/K8FFo.jpg?s=328&g=1',
placeholder: (context, url) => CircularProgressIndicator(), //<= ends here
errorWidget: (context, url, error) => Icon(Icons.error)),
);
}
}
OUTPUT
With padding: EdgeInsets.all(0.0),
Without padding: EdgeInsets.all(0.0),

change drawer item icon to right flutter

I used drawer in the flutter, and I user end drawer to change the direction the drawer,
but I need also change the direction of drawer item icon to right flutter, how can I do it?
You can achieve this using ListTile widgets
Try this way
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
void main() => runApp( HomeApp());
class HomeApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
// TODO: implement build
return new MaterialApp(
theme: new ThemeData(
primarySwatch: Colors.deepPurple,
brightness: Brightness.light,
accentColor: Colors.red),
home: new HomePage(),
);
}
}
class HomePage extends StatefulWidget {
#override
_HomePageScreen createState() => _HomePageScreen();
}
class _HomePageScreen extends State<HomePage> {
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Home"),
),
endDrawer: Drawer(
child: ListView(
padding: EdgeInsets.all(0.0),
children: <Widget>[
UserAccountsDrawerHeader(
accountName: Text("Nilesh Rathod"),
accountEmail: Text("nilesh#gmail.com"),
currentAccountPicture: CircleAvatar(
backgroundColor: Colors.white,
child: Text("Nilu"),
),
otherAccountsPictures: <Widget>[
CircleAvatar(
backgroundColor: Colors.white,
child: Text("Pilu"),
),
],
),
ListTile(
title: Text("Home"),
trailing: Icon(Icons.new_releases),
),
Divider(),
ListTile(
title: Text("Profile"),
trailing: Icon(Icons.person),
onTap: () => {},
),
Divider(),
ListTile(
title: Text("Tab Layout"),
trailing: Icon(Icons.person),
onTap: () => {},
),
Divider(),
ListTile(
title: Text("Comman View Demo"),
trailing: Icon(Icons.person),
onTap: () => {},
),
Divider(),
ListTile(
title: Text("Close"),
trailing: Icon(Icons.close),
onTap: () => Navigator.of(context).pop(),
),
],
),
),
body: Center(
child: Text("Home Screen"),
),
);
}
}
SAMPLE CODE
Make use of ListTile trailing property
ListTile(
title: Text("text"),
trailing: Icon(Icons.account),
onTap:null,
),