Why does this code display a blank screen when running? - android

Before displaying the code, here are the things that I checked to avoid similar answers :
android:extratNativeLibs="true"
Jsonfile firebase connected
routegenerator and initialroute checked in the main file and
generatorfile
.I like to avoid mediaQuery and work with percentages, that is why I use FractionallySizedBox. Here is the code of the initial route :
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class Start extends StatelessWidget {
const Start({Key? key}) : super(key: key);
#override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Align(
alignment: Alignment.center,
child: Center(
child: Column(mainAxisSize: MainAxisSize.min, children: <Widget>[
FractionallySizedBox(widthFactor: 0.15, heightFactor: 0.15, child: Image.asset('assets/crown.png')),
FractionallySizedBox(
widthFactor: 0.40,
heightFactor: 0.20,
child: TextButton(
onPressed: () {
Navigator.of(context).pushNamed('/items');
},
child: Container(
decoration: BoxDecoration(color: Colors.purple),
child: Row(mainAxisSize: MainAxisSize.min, children: <Widget>[
const Text('Start shopping',
style: TextStyle(
color: Colors.white,
fontStyle: FontStyle.italic,
fontSize: 25,
)),
Image.asset('assets/crown.png')
]))))
])))));
}
}

Warp your FractionallySizedBox with Expanded
Expanded(
child: FractionallySizedBox(
widthFactor: 0.15,
heightFactor: 0.15,
child: Image.asset('assets/crown.png')),
),
Expanded(
child: FractionallySizedBox(
widthFactor: 0.40,
heightFactor: 0.20,
child: TextButton(
onPressed: () {
Navigator.of(context).pushNamed('/items');
},
child: Container(
decoration: BoxDecoration(color: Colors.purple),
child: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
const Text('Start shopping',
style: TextStyle(
color: Colors.white,
fontStyle: FontStyle.italic,
fontSize: 25,
)),
Image.asset('assets/crown.png')
],
),
),
),
),
),

Related

Bottom align clipped image in Flutter

Bottom align clipped image in Flutter
Hello!
I'm beginner in Flutter
The following image:
I clipped the lettuce image in half with ClipPath:
I'm trying to move it into bottom right to be similar to the following image:
I tried many times with my available experience with no luck
Here's the code:
class GroceryPage extends StatelessWidget {
const GroceryPage({Key? key}) : super(key: key);
#override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Padding(
padding: const EdgeInsets.all(15.0),
child: SingleChildScrollView(
child: Column(
children: [
const SizedBox(height: 10.0),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30.0),
color: const Color(0xFFE9F9F2),
),
width: double.infinity,
child: Stack(
children: [
ClipPath(
clipper: HalfClip(),
child: Align(
alignment: Alignment.bottomRight,
child: Image.asset(
'${kProductsImagesAsset}lettuce.png',
height: 150,
// width: 150,
fit: BoxFit.cover,
),
),
),
Padding(
padding: const EdgeInsets.all(40.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Get Up To',
style: kGreenTitleStyle.copyWith(
fontSize: 20.0,
),
),
Text(
'%10 off',
style: kGreenTitleStyle.copyWith(
fontSize: 40.0,
),
),
],
),
),
],
),
),
],
),
),
),
),
);
}
}
Can anyone help me doing so?
Use Positioned widget as Stack child.
Positioned(
top: 0,
left: 0,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Get Up To',
style: kGreenTitleStyle.copyWith(
fontSize: 20.0,
),
),
Text(
'%10 off',
style: kGreenTitleStyle.copyWith(
fontSize: 40.0,
),
),
],
),
),
More about using Stack
class GroceryPage extends StatelessWidget {
const GroceryPage({Key? key}) : super(key: key);
#override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Padding(
padding: const EdgeInsets.all(15.0),
child: SingleChildScrollView(
child: Column(
children: [
const SizedBox(height: 10.0),
Container(
height: 300, //cardHeight
clipBehavior: Clip.hardEdge,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30.0),
color: const Color(0xFFE9F9F2),
),
child: Stack(
children: [
Align(
child: Container(
height: 600, // full image height= cardHeight*2
color: Colors.red,
),
// child: Image.asset(
// '${kProductsImagesAsset}lettuce.png',
// height: 150,
// // width: 150,
// fit: BoxFit.cover,
// ),
),
Positioned(
top: 0,
left: 0,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Get Up To',
style: TextStyle(
fontSize: 20.0,
),
),
Text(
'%10 off',
style: TextStyle(
fontSize: 40.0,
),
),
],
),
),
],
),
),
],
),
),
),
),
);
}
}

Flutter Listview can't scroll and not display all list

i just started with flutter. in my case, i want to show 10 items listview on my home page. but that listview only shows 9 items. listview cannot be scrolled to show other item. can you see whats wrong with my code?
I have been looking for a solution to this problem by looking for a topic that has the same title, but nothing. i have changed some lines of my code but i get error "bottom overlow by 240px"
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);
#override
_HomePageState createState() => _HomePageState();
}
Future<Null> _fetchPartner() async {
print('Please Wait');
}
class _HomePageState extends State<HomePage> {
#override
Widget build(BuildContext context) {
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle(statusBarColor: Colors.transparent),
);
return Scaffold(
resizeToAvoidBottomInset: false,
body: RefreshIndicator(
onRefresh: _fetchPartner,
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
physics: AlwaysScrollableScrollPhysics(),
child: Column(
children: <Widget>[
Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding:
const EdgeInsetsDirectional.only(top: 18, bottom: 18),
child: Text("Powered By:",
style: new TextStyle(fontSize: 18.0)),
)
],
),
ListView.builder(
padding: EdgeInsets.zero,
shrinkWrap: true,
itemCount: 10,
itemBuilder: (BuildContext context, int index) {
return Card(
margin: EdgeInsets.zero,
elevation: 0.4,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(0),
),
child: Container(
child: ListTile(
leading: CircleAvatar(
child: Image.network(
"https://via.placeholder.com/150")),
title: Text(
"Coconut Oil",
style: TextStyle(
color: Colors.black87,
fontWeight: FontWeight.bold),
),
subtitle: Row(
children: <Widget>[
Icon(Icons.linear_scale,
color: Colors.greenAccent),
Text("Go Green!",
style:
TextStyle(color: Colors.black87))
],
),
trailing: Icon(Icons.keyboard_arrow_right,
color: Colors.black87, size: 30.0))));
})
],
),
),
));
}
}
Try below code Its working properly:
SingleChildScrollView(
child: Column(
children: <Widget>[
Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsetsDirectional.only(top: 18, bottom: 18),
child: Text(
"Powered By:",
style: new TextStyle(fontSize: 18.0),
),
)
],
),
ListView.builder(
padding: EdgeInsets.zero,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemCount: 10,
itemBuilder: (BuildContext context, int index) {
return Card(
margin: EdgeInsets.zero,
elevation: 0.4,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(0),
),
child: Container(
child: ListTile(
leading: CircleAvatar(
child:
Image.network("https://via.placeholder.com/150")),
title: Text(
"Coconut Oil",
style: TextStyle(
color: Colors.black87, fontWeight: FontWeight.bold),
),
subtitle: Row(
children: <Widget>[
Icon(Icons.linear_scale, color: Colors.greenAccent),
Text(
"Go Green!",
style: TextStyle(color: Colors.black87),
)
],
),
trailing: Icon(
Icons.keyboard_arrow_right,
color: Colors.black87,
size: 30.0,
),
),
),
);
},
)
],
),
),
Your result screen:
Add this property to Listivew.Builder
physics : NeverScrollableScrollPhysics()
as it is inside SingleChildScrollView.
Add this line to your code.
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);
#override
_HomePageState createState() => _HomePageState();
}
Future<Null> _fetchPartner() async {
print('Please Wait');
}
class _HomePageState extends State<HomePage> {
#override
Widget build(BuildContext context) {
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle(statusBarColor: Colors.transparent),
);
return Scaffold(
resizeToAvoidBottomInset: false,
body: RefreshIndicator(
onRefresh: _fetchPartner,
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
physics: AlwaysScrollableScrollPhysics(),
child: Column(
children: <Widget>[
Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding:
const EdgeInsetsDirectional.only(top: 18, bottom: 18),
child: Text("Powered By:",
style: new TextStyle(fontSize: 18.0)),
)
],
),
ListView.builder(
padding: EdgeInsets.zero,
physics : NeverScrollableScrollPhysics()
shrinkWrap: true,
itemCount: 10,
itemBuilder: (BuildContext context, int index) {
return Card(
margin: EdgeInsets.zero,
elevation: 0.4,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(0),
),
child: Container(
child: ListTile(
leading: CircleAvatar(
child: Image.network(
"https://via.placeholder.com/150")),
title: Text(
"Coconut Oil",
style: TextStyle(
color: Colors.black87,
fontWeight: FontWeight.bold),
),
subtitle: Row(
children: <Widget>[
Icon(Icons.linear_scale,
color: Colors.greenAccent),
Text("Go Green!",
style:
TextStyle(color: Colors.black87))
],
),
trailing: Icon(Icons.keyboard_arrow_right,
color: Colors.black87, size: 30.0))));
})
],
),
),
));
}
}
Remove the singleChildScrollview and add a expanded widget on the listview.builder.
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);
#override
_HomePageState createState() => _HomePageState();
}
Future<Null> _fetchPartner() async {
print('Please Wait');
}
class _HomePageState extends State<HomePage> {
#override
Widget build(BuildContext context) {
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle(statusBarColor: Colors.transparent),
);
return Scaffold(
resizeToAvoidBottomInset: false,
body: RefreshIndicator(
onRefresh: _fetchPartner,
child: Column(
children: <Widget>[
Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding:
const EdgeInsetsDirectional.only(top: 18, bottom: 18),
child: Text("Powered By:",
style: new TextStyle(fontSize: 18.0)),
)
],
),
Expanded(
child : ListView.builder(
padding: EdgeInsets.zero,
shrinkWrap: true,
itemCount: 10,
itemBuilder: (BuildContext context, int index) {
return Card(
margin: EdgeInsets.zero,
elevation: 0.4,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(0),
),
child: Container(
child: ListTile(
leading: CircleAvatar(
child: Image.network(
"https://via.placeholder.com/150")),
title: Text(
"Coconut Oil",
style: TextStyle(
color: Colors.black87,
fontWeight: FontWeight.bold),
),
subtitle: Row(
children: <Widget>[
Icon(Icons.linear_scale,
color: Colors.greenAccent),
Text("Go Green!",
style:
TextStyle(color: Colors.black87))
],
),
trailing: Icon(Icons.keyboard_arrow_right,
color: Colors.black87, size: 30.0))));
})
],
),
),
));
}
}
Please try with this code
replace your body tag with this and let me know
Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsetsDirectional.only(top: 18, bottom: 18),
child:
Text("Powered By:", style: new TextStyle(fontSize: 18.0)),
)
],
) ,
Expanded ( child : ListView.builder(
padding: EdgeInsets.zero,
shrinkWrap: true,
itemCount: 13,
itemBuilder: (BuildContext context, int index) {
return Card(
margin: EdgeInsets.zero,
elevation: 0.4,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(0),
),
child: Container(
child: ListTile(
leading: CircleAvatar(
child: Image.network(
"")),
title: Text(
"Coconut Oil",
style: TextStyle(
color: Colors.black87,
fontWeight: FontWeight.bold),
),
subtitle: Row(
children: <Widget>[
Icon(Icons.linear_scale,
color: Colors.greenAccent),
Text("Go Green!",
style: TextStyle(color: Colors.black87))
],
),
trailing: Icon(Icons.keyboard_arrow_right,
color: Colors.black87, size: 30.0))));
}) )
]
)
I am not convinced that any of the provided solutions is the right one. All of them use shrinkWrap: true. With only 10 elements this should not impact performance, but when it changes to 10k, well it will be a problem. I would simplify the tree by removing SingleChildScrollView and Column, moving Row from Column to ListView.builder, and displaying it only when the index == 0. We need to remember to add 1 in itemCount and remove shrinkWrap. There is another solution with the use of SliverList, but it would complicate too much without additional benefits. Below is the code for the first solution.
class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);
#override
_HomePageState createState() => _HomePageState();
}
Future<Null> _fetchPartner() async {
print('Please Wait');
}
class _HomePageState extends State<HomePage> {
#override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
body: RefreshIndicator(
onRefresh: _fetchPartner,
child: ListView.builder(
itemCount: 10 + 1,
itemBuilder: (BuildContext context, int index) {
if (index == 0) {
return Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsetsDirectional.only(
top: 18, bottom: 18),
child: Text("Powered By:",
style: new TextStyle(fontSize: 18.0)),
)
],
);
}
return Card(
margin: EdgeInsets.zero,
elevation: 0.4,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(0),
),
child: Container(
child: ListTile(
leading: CircleAvatar(
child: Image.network(
"https://via.placeholder.com/150")),
title: Text(
"Coconut Oil",
style: TextStyle(
color: Colors.black87,
fontWeight: FontWeight.bold),
),
subtitle: Row(
children: <Widget>[
Icon(Icons.linear_scale,
color: Colors.greenAccent),
Text("Go Green!",
style: TextStyle(color: Colors.black87))
],
),
trailing: Icon(Icons.keyboard_arrow_right,
color: Colors.black87, size: 30.0))));
}),
));
}
}

type 'Future<dynamic>' is not a subtype of type 'Route<Object>'

I got the the following error for below code. I was attempting to navigate to the next page. I was able to navigate just once and then I got the error mentioned above. Please do help me on this. I tried even using await but await is not supported for builder: (BuildContext context) => SubmitArticles()).
class UserSubmitOption extends StatefulWidget {
#override
_UserSubmitOptionState createState() => _UserSubmitOptionState();
}
class _UserSubmitOptionState extends State<UserSubmitOption> {
#override
Widget build(BuildContext dynamic) => MaterialApp(
debugShowCheckedModeBanner: false,
home:SafeArea (
child: Scaffold(
backgroundColor: Colors.indigo[800],
resizeToAvoidBottomInset: false,
appBar: AppBar(
toolbarHeight: 60,
backgroundColor: Colors.indigo[900],
automaticallyImplyLeading: false,
title: Text("What do you want to submit?",style:TextStyle(color:Colors.white,fontWeight:FontWeight.bold)),
centerTitle: true,
leading: IconButton(
icon: Icon(Icons.arrow_back,color:Colors.black,size:25,),
onPressed: () => Navigator.push(context,
MaterialPageRoute(builder: (context) => UserMenu())))),
body: SafeArea(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Padding(
padding: const EdgeInsets.all(60.0),
child: Center(
child: Wrap(spacing: 50, runSpacing: 50.0, children: <Widget>[
GestureDetector(
onTap: () {
SubmitQuiz();
setState(() {
});
},
child: SizedBox(
width: 200.0,
height: 200.0,
child: Card(
color: Colors.indigo,
borderOnForeground:true,
shadowColor: Colors.white,
elevation: 20.0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(100.0)),
child: Center(
child: Padding(
padding: const EdgeInsets.all(50.0),
child: Column(
children: <Widget>[
Icon(
Icons.vpn_key_outlined,size:60,color:Colors.black,
), // Image.asset("assets/todo.png",width: 64.0,),
SizedBox(
height: 7.0,
),
Text(
"Quiz",
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 17.0,
),
),
SizedBox(
height: 5.0,
),
],
),
)),
),
)),
GestureDetector(
onTap: () async {Navigator.push(context,
MaterialPageRoute (
builder: (BuildContext context) => SubmitArticles())
);},
child: SizedBox(
width: 200.0,
height: 200.0,
child: Card(
color: Colors.indigo,
elevation: 20.0,
shadowColor:Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(100.0)),
child: Center(
child: Padding(
padding: const EdgeInsets.all(45.0),
child: Column(
children: <Widget>[
Icon (
Icons.article_outlined,size:60,
),
// Image.asset("assets/note.png",width: 64.0,),
SizedBox(
height: 7.0,
),
Text(
"Articles",
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 17.0),
),
SizedBox(
height: 5.0,
),
],
),
)),
),
)),
]),
),
),
],
),
),
)));
}
You are trying to access route in the wrong way
use instead:
Navigator.push(context,MaterialPageRoute(
builder : (context) => SubmitArticles())
);
i hope it work with you.
happy coding!

Using TabBarView with DraggableScrollableSheet in Flutter

I am developing a city travel guide application for my project. In this project, I have page like this:
Screenshot
In this page, I want to make the container with red border scrollable vertically until green line with DraggableScrollableSheet . And also I want to add TabBarView to the same container and scroll horizontally.
But I can not handle, encountered with many render errors.
How can i fix this?
Here is the full code:
import 'package:after_layout/after_layout.dart';
import 'package:flutter/material.dart';
class CategoryScreen extends StatefulWidget {
final double _expandedBottomSheetBottomPosition = 0;
final townimage;
const CategoryScreen({Key key, this.townimage}) : super(key: key);
#override
_CategoryScreen createState() => _CategoryScreen(
townimage: this.townimage,
);
}
class _CategoryScreen extends State<CategoryScreen>
with TickerProviderStateMixin, AfterLayoutMixin<CategoryScreen> {
var townimage;
_CategoryScreen({this.townimage});
double _bottomSheetBottomPosition = -330;
bool isCollapsed = false;
TabController _tabController;
#override
void initState() {
super.initState();
_tabController = TabController(length: 2, vsync: this);
}
#override
Widget build(BuildContext context) {
return Scaffold(
extendBodyBehindAppBar: true,
appBar: AppBar(elevation: 0, backgroundColor: Colors.transparent),
body: Container(
child: Stack(
fit: StackFit.expand,
children: <Widget>[
Hero(
tag: "image" + townimage,
child: Image.asset(
"images/photos/turkey.jpg",
fit: BoxFit.cover,
)),
AnimatedPositioned(
duration: const Duration(milliseconds: 500),
curve: Curves.decelerate,
bottom: _bottomSheetBottomPosition,
left: 0,
right: 0,
child: Column(
children: [
_tabBar(),
Container(
decoration: BoxDecoration(
border: Border.all(color: Colors.red, width: 3.0),
color: Theme.of(context).canvasColor,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(40),
topRight: Radius.circular(40),
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
alignment: Alignment.centerLeft,
padding: const EdgeInsets.symmetric(horizontal: 32),
height: 90,
child: Row(
children: [
Text(
"Historical Places",
style: TextStyle(
fontSize: 28.0,
color: Colors.white,
fontWeight: FontWeight.bold),
),
],
),
),
SingleChildScrollView(
physics: ScrollPhysics(),
child: _clipsWidget(),
),
],
),
),
],
),
),
],
),
),
);
}
Widget _clipsWidget() {
return Container(
color: Theme.of(context).canvasColor,
height: 250,
margin: const EdgeInsets.symmetric(horizontal: 16),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.account_balance_rounded),
Text("I want to add TabBarView to this area"),
Text(
"Some Future Builder elements will be implemented.",
)
],
),
));
}
#override
void afterFirstLayout(BuildContext context) {
Future.delayed(const Duration(milliseconds: 500), () {
setState(() {
isCollapsed = true;
_bottomSheetBottomPosition = widget._expandedBottomSheetBottomPosition;
});
});
}
Widget _tabBar() {
return TabBar(
controller: _tabController,
indicatorColor: Colors.transparent,
isScrollable: true,
labelColor: Colors.white,
unselectedLabelColor: Colors.grey,
labelPadding: EdgeInsets.symmetric(horizontal: 10),
tabs: [
Container(
height: 70,
child: Tab(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
margin: EdgeInsets.all(5),
padding: EdgeInsets.all(10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(100),
color: Theme.of(context).canvasColor.withOpacity(0.8),
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Icon(
Icons.account_balance_rounded,
),
),
),
],
)),
),
Container(
height: 70,
child: Tab(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
margin: EdgeInsets.all(5),
padding: EdgeInsets.all(10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(100),
color: Theme.of(context).canvasColor.withOpacity(0.8),
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Icon(
Icons.park,
),
),
),
],
)),
),
]);
}
}

How to align text left inside a button, which is inside a centre widget | Flutter?

my buttons are must be on center but must aligned in same line ,
the text in side button also should aligned left.
for that i use textalign left but not works in my code , I dont know why.This is my layout screenshot.
So Can anyone modify my code so that the text inside button aligned left ,without affecting my buttons position .
Thank you
class Something extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Solve Before Downvote !'),
),
body: Container(
color: Color(0xff263238),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SingleChildScrollView(
child: Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
MaterialButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0)),
padding: EdgeInsets.only(left: 5),
color: Colors.green,
onPressed: () {},
child: Text('SomeThing', textAlign: TextAlign.left),
),
MaterialButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0)),
color: Colors.green,
onPressed: () { },
child: Text('Nothing', textAlign: TextAlign.left),
),
MaterialButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0)),
color: Colors.green,
onPressed: () {},
child: Text('Can You do something ?',
textAlign: TextAlign.left),
),
MaterialButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0)),
color: Colors.green,
onPressed: () {},
child: Text('Nothing to do !', textAlign: TextAlign.left),
),
],
),
),
)
],
),
),
);
}
}
what i made
Please check the below code. I have comment out the solution in code.
class Something extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Solve Before Downvote !'),
),
body: Container(
width: MediaQuery.of(context).size.width,
color: Color(0xff263238),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SingleChildScrollView(
child: Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.all(2.0),
child: Material(
color: Colors.green,
borderRadius: BorderRadius.circular(10.0),
child: InkWell(
onTap: () {
setState(() {
abc = true;
});
},
child: Padding(
padding: const EdgeInsets.fromLTRB(0, 12, 15, 12),
child: Text('SomeThing', textAlign: TextAlign.left),
),
),
),
),
Padding(
padding: const EdgeInsets.all(2.0),
child: Material(
color: Colors.green,
borderRadius: BorderRadius.circular(10.0),
child: InkWell(
onTap: () {
setState(() {
abc = true;
});
},
child: Padding(
padding: const EdgeInsets.fromLTRB(0, 12, 15, 12),
child: Text('Nothing', textAlign: TextAlign.left),
),
),
),
),
Padding(
padding: const EdgeInsets.all(2.0),
child: Material(
color: Colors.green,
borderRadius: BorderRadius.circular(10.0),
child: InkWell(
onTap: () {
setState(() {
abc = true;
});
},
child: Padding(
padding: const EdgeInsets.fromLTRB(0, 12, 15, 12),
child: Text('Can You do something ?',
textAlign: TextAlign.left),
),
),
),
),
Padding(
padding: const EdgeInsets.all(2.0),
child: Material(
color: Colors.green,
borderRadius: BorderRadius.circular(10.0),
child: InkWell(
onTap: () {
setState(() {
abc = true;
});
},
child: Padding(
padding: const EdgeInsets.fromLTRB(0, 12, 15, 12),
child: Text('Nothing to do !',
textAlign: TextAlign.left),
),
),
),
),
],
),
),
)
],
),
),
);
}
}
Can you add Align() and set alignment : Alignment.centerLeft before widget child text

Categories

Resources