Flutter build_runner fails to build when added third party generator - flutter

I wrote a flutter project which working fine and I was able to build it properly, but when I added retrofit_generator the build getting failed, If i remove the generator the code runs fine and the build also succeeds. here is the error,
Unsupported operation: Cannot resolve
file:///C:/Users/User/AndroidStudioProjects/digigad/lib/resources/network/reposi
tory.dart; only "package" and "asset" schemes supported
[SEVERE] retrofit_generator:retrofit on lib/ui/login/login_view.dart:
here is my code of login_view.dart
class LoginView extends StatefulWidget {
#override
_LoginViewState createState() => _LoginViewState();
}
class _LoginViewState extends State<LoginView> {
LoginViewModel _loginViewModel;
#override
void initState() {
super.initState();
_loginViewModel = locator<LoginViewModel>();
}
#override
Widget build(BuildContext context) {
return ViewModelBuilder<LoginViewModel>.nonReactive(
builder: (context, model, child) {
return Scaffold(
backgroundColor: Colors.white,
body: SafeArea(
child: Padding(
padding: const EdgeInsets.all(30.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Container(
child: Center(
child: Container(
child: Image.asset('images/iv_logo.png'),
width: 100,
height: 100,
),
),
),
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
_socialButton(
image: 'icons/ic_facebook.png',
title: 'Facebook'),
SizedBox(
width: 30,
),
_socialButton(
image: 'icons/ic_google.png', title: 'Google'),
],
),
SizedBox(
height: 30,
),
Text(
'or',
style: TextStyle(
fontSize: 15, color: AppConstants.colorHint),
),
SizedBox(
height: 20,
),
StreamBuilder<String>(
stream: model.phoneStream,
builder: (context, snapshot) {
return Column(
children: <Widget>[
AppFunctions.getTextInputField(
hintText: 'Mobile Number',
maxLength: 10,
inputType: TextInputType.phone,
onChanged: model.onPhoneChanged,
errorText: snapshot.error),
AppFunctions.getStandardDivider(),
AppFunctions.getBigButton(
title: 'Login',
color: snapshot.hasData
? AppConstants.colorPrimary
: AppConstants.colorHint,
onClick: snapshot.hasData
? () => _loginViewModel
.onLoginClicked(snapshot.data)
: () => () {},
)
],
);
}),
],
),
Center(
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text('Made with '),
Icon(
Icons.favorite,
color: Colors.red,
),
Text(' in Flutter'),
],
),
),
],
),
),
),
);
},
viewModelBuilder: () => _loginViewModel);
}
Expanded _socialButton({String image, String title}) {
return Expanded(
child: Container(
height: 40,
child: RaisedButton(
onPressed: () {},
color: Colors.white,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Image.asset(
image,
width: 16,
height: 16,
),
SizedBox(
width: 10,
),
Text(title)
],
),
),
),
);
}
}

I also faced the same error and got to know that there is some direct import statement in my project file.
that import statement was login_page.dart
import 'file:///D:/Major_Project/connect/lib/api/api.dart';
in this case, the same error was thrown in build
Log
so find that statement in the project and change it with the normal import statement
login_page.dart
import 'package:connect/api/api.dart';

So as the first answer points out, this error is because you have an unsupported import somewhere in your code.
import 'file:///D:/Major_Project/connect/lib/api/api.dart';
The easiest solution is to delete that import. A better solution is to add the following line to your analysis_options.yaml page so that every weird import like this get's linted:
analyzer:
errors:
invalid_uri: error
You can read more about this lint here. If you have a giant project or you find yourself constantly refactoring your folder structure, this will save you a ton of time.

Related

Flutter - how to position the background to the bottom with stack

I'm a beginner at app dev and I'm trying out flutter. I'm currently having a problem with positioning my background on the project that I am currently testing out.I'm following a UI kit that I am trying to copy for the purpose of practicing, but I am having problem with the UI.
I tried using stack but the whole screen is wrapped with its children and not taking up space. it looks like this:
and this is what I wanted to do:
This is the background that I wanted to put in my app, it is not literally a background or wallpaper because of its size. I just needed this to be placed at the bottom of the screen or background:
this is the code that I currently have:
import 'package:audit_finance_app/constant/theme.dart';
import 'package:audit_finance_app/widgets/widgets.dart';
import 'package:audit_finance_app/screens/homescreen.dart';
import 'package:flutter/material.dart';
import 'dart:math' as math;
class SignInPage extends StatefulWidget {
const SignInPage({super.key});
#override
State<SignInPage> createState() => _SignInPageState();
}
class _SignInPageState extends State<SignInPage> {
late List<String> inputPass;
String defaultPass = '1234';
#override
void initState() {
inputPass = [];
super.initState();
}
#override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
fit: StackFit.expand,
children: <Widget>[
const SizedBox(
width: double.maxFinite,
height: double.maxFinite,
child: Image(
image: AssetImage('assets/background.png'),
),
),
CustomScrollView(
slivers: <Widget>[
SliverAppBar(
pinned: true,
flexibleSpace: Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: [
AuditTheme.primaryColor,
AuditTheme.secondaryColor,
],
),
),
),
leadingWidth: 100,
leading: Padding(
padding: const EdgeInsets.fromLTRB(10, 0, 0, 0),
child: Row(
children: const [
Expanded(
child: ImageIcon(
AssetImage('assets/logo/white_logo.png'),
),
),
Text(
'Audit',
style: TextStyle(fontSize: 20),
),
],
),
),
title: const Text('Sign In'),
centerTitle: true,
actions: [
Transform(
alignment: Alignment.center,
transform: Matrix4.rotationY(math.pi),
child: IconButton(
onPressed: () {},
icon: const Icon(Icons.sort),
),
),
],
),
SliverList(
delegate: SliverChildListDelegate(
[
Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Widgets().sixedBoxHeight(50),
Column(
children: [
const CircleAvatar(
radius: 35,
backgroundImage:
AssetImage('assets/logo/audit_logo.png'),
),
Widgets().sixedBoxHeight(10),
const Text(
'Ledjoric Vermont',
style: TextStyle(fontSize: 20),
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
pinIconTest(inputPass.isNotEmpty
? Colors.black
: Colors.grey),
pinIconTest(inputPass.length >= 2
? Colors.black
: Colors.grey),
pinIconTest(inputPass.length >= 3
? Colors.black
: Colors.grey),
pinIconTest(inputPass.length == 4
? Colors.black
: Colors.grey),
],
),
Card(
child: Column(
children: [
Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
numPad(const Text('1'), () => inputPin('1')),
numPad(const Text('2'), () => inputPin('2')),
numPad(const Text('3'), () => inputPin('3')),
],
),
Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
numPad(const Text('4'), () => inputPin('4')),
numPad(const Text('5'), () => inputPin('5')),
numPad(const Text('6'), () => inputPin('6')),
],
),
Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
numPad(const Text('7'), () => inputPin('7')),
numPad(const Text('8'), () => inputPin('8')),
numPad(const Text('9'), () => inputPin('9')),
],
),
Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.end,
children: [
const SizedBox(
width: 100,
height: 100,
),
numPad(const Text('0'), () => inputPin('0')),
numPad(
const Icon(Icons.backspace_sharp),
() => deletePin(),
),
],
),
],
),
),
],
),
],
),
),
],
),
],
),
);
}
Widget pinIconTest(Color color) {
return Padding(
padding: const EdgeInsets.all(5.0),
child: Icon(
Icons.circle,
size: 35,
color: color,
),
);
}
Widget numPad(Widget widget, void Function() function) {
return SizedBox(
width: 100,
height: 100,
child: TextButton(
style: TextButton.styleFrom(
foregroundColor: Colors.grey,
textStyle: const TextStyle(
fontSize: 30,
),
),
onPressed: function,
child: widget,
),
);
}
void inputPin(String value) {
setState(() {
inputPass.length != 4 ? inputPass.add(value) : null;
inputPass.length == 4 ? checkPass() : null;
});
print(inputPass);
}
void checkPass() {
var stringList = inputPass.join('');
if (stringList == defaultPass) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const HomeScreen(),
),
);
}
print(stringList);
}
void deletePin() {
setState(() {
inputPass.isNotEmpty ? inputPass.removeLast() : null;
});
print(inputPass);
}
}
I was missing the fact you want to place at the bottom that background, however to achieve that you can do it as the code below shows:
class SignInPage extends StatefulWidget {
const SignInPage({super.key});
#override
State<SignInPage> createState() => _SignInPageState();
}
class _SignInPageState extends State<SignInPage> {
#override
void initState() {
super.initState();
}
#override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
fit: StackFit.expand,
children: <Widget>[
const Align(
alignment: Alignment.bottomCenter,
child: Image(
image: AssetImage('assets/background.png'),
),
),
//Other child here
],
),
);
}
}
And this is the result:
You can use the example below for the status bar. I don't know about the real problem.
You can try using this way for gradient color
SystemUiOverlayStyle systemUiOverlayStyle = SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
statusBarIconBrightness: Brightness.light,
statusBarBrightness: Brightness.dark,
statusBarGradient: LinearGradient(
colors: [Colors.red, Colors.blue],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
);
You need to wrap your image in a Positioned Widget.
Positioned(bottom: 0.0,
child: const SizedBox(
width: double.maxFinite,
height: double.maxFinite,
child: Image(
image: AssetImage('assets/background.png'),
),
),
Or you can use the alignment property of the Stack to stick everything onto the bottom. I'm not sure this is exactly what you want though.
body: Stack(
alignment: Alignment.bottomCenter,
fit: StackFit.expand,
children: <Widget>[
const SizedBox(
width: double.maxFinite,
height: double.maxFinite,
child: Image(
image: AssetImage('assets/background.png'),
),
),

The getter 'length' was called on null in flutter

I have added three streamBuilder on my homepage and all the StreamBuilders fetch different data from cloud firestore but i am getting 'The getter 'length' was called on null in flutter' . I have tried to look for a solution on the internet but all in vain. Am getting this error:
════════ Exception caught by widgets library ═══════════════════════════════════
The getter 'length' was called on null.
Receiver: null
Tried calling: length
The relevant error-causing widget was
StreamBuilder<List<Order>>
lib/…/home/home.dart:52
Here is my home.dart:
import 'package:flutter/material.dart';
import 'package:merza/models/orders.dart';
import 'package:merza/models/user.dart';
import 'package:merza/screens/home/items.dart';
import 'package:merza/screens/home/orders/delivered_order.dart';
import 'package:merza/screens/home/orders/order_status.dart';
import 'package:merza/screens/user/add_order.dart';
import 'package:merza/services/auth.dart';
import 'package:merza/services/databse.dart';
import 'package:merza/shared/grid.dart';
import 'package:intl/intl.dart';
import 'package:merza/shared/menus.dart';
import 'package:merza/shared/splash_screen.dart';
import 'package:provider/provider.dart';
import 'package:merza/screens/home/orders/orders_list.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'orders/orders_tile.dart';
class Home extends StatelessWidget {
//Auth
AuthService _auth = AuthService();
//Database
Database _db = Database();
#override
Widget build(BuildContext context) {
final user = Provider.of<User>(context);
if(user.uid == null){
Navigator.pushNamedAndRemoveUntil(context, "/home", (r) => false);
}else{
return StreamBuilder<UserData>(
stream: Database(uid: user.uid).userData,
builder: (context, snapshot) {
if (snapshot.hasData) {
UserData userData = snapshot.data;
//Streambuilder for delivered orders
return StreamBuilder<List<Order>>(
stream: Database(receiver_nrc: userData.nrc, paramOne: 'payment_status', paramValue: 'unpaid').dataFetch,
builder: (context, snapshot2) {
String count_unpaid = snapshot2.data.length.toString();
if (snapshot2.hasData) {
return StreamBuilder <List<Order>>(
stream: Database(receiver_nrc: userData.nrc, paramOne: 'order_status', paramValue: 'delivered').dataFetch,
builder: (context, snapshot3) {
String count_awaiting = snapshot3.data.length.toString();
if (snapshot3.hasData) {
return StreamProvider<List<Order>>.value(
value: Database(receiver_nrc: userData.nrc).orders,
child: Scaffold(
appBar: LoggedBar(title: 'Merza',),
body: SingleChildScrollView(
child: Column(
children: [
Container(), // Required some widget in between to float AppBar
Container( // To take AppBar Size only
child: AppBar(
elevation: 0.0,
backgroundColor: Colors.white,
leading: IconButton(icon: Icon(Icons.home), color: Colors.green[900], onPressed: (){
Navigator.push(context, MaterialPageRoute(builder: (context) => Home()));
},),
primary: false,
title: TextField(
decoration: InputDecoration(
hintText: "Search",
border: InputBorder.none,
hintStyle: TextStyle(color: Colors.green[900]))),
actions: <Widget>[
IconButton(
icon: Icon(Icons.search, color: Colors.green[900]), onPressed: () {},),
],
),
),
Container(
color: Colors.green,
padding: EdgeInsets.symmetric(vertical: 20.0, horizontal: 20.0),
child: Text('A TRADING ZONE THAT PROMOTES SAFETY TRADING AND SECURE DIGITAL TRANSACTIONS', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14, color: Colors.white)),
), Container(
margin: EdgeInsets.symmetric(vertical: 10.0, horizontal: 20.0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: Card(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Container(
width: 130,
child: ListTile(
title: Image.network('https://madvertadvertising.com/media/merza/images/seller.jpeg'),
onTap: (){
// Navigator.push(context, MaterialPageRoute(builder: (context) => ItemsPage()));
},
),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const SizedBox(width: 8),
],
),
],
),
),
),
Expanded(
child: Card(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Container(
width: 130,
child: ListTile(
title: Image.network('https://madvertadvertising.com/media/merza/images/delivery.jpeg'),
onTap: (){
Navigator.push(context, MaterialPageRoute(builder: (context) => AwaitingOrdersList(nrc: userData.nrc, paramValueOne: 'order_status', paramValueTwo: 'delivered', barTitle: 'Delivered', isStaff: userData.is_staff.toString(), allowStaffPrivaledges: 'no',)));
},
),
),
const SizedBox(width: 8),
],
),
),
),
],
),
),
Container(
margin: EdgeInsets.symmetric(vertical: 10.0, horizontal: 20.0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: Card(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Container(
width: 130,
child: ListTile(
title: Image.network('https://madvertadvertising.com/media/merza/images/items.jpeg'),
onTap: (){
Navigator.push(context, MaterialPageRoute(builder: (context) => ItemsPage()));
},
),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const SizedBox(width: 8),
],
),
],
),
),
),
Expanded(
child: Container(
child: Card(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Container(
width: 130,
child: ListTile(
title: Image.network('https://madvertadvertising.com/media/merza/images/payment.jpeg'),
onTap: (){
Navigator.push(context, MaterialPageRoute(builder: (context) => DeliverdordersList(nrc: userData.nrc, paramValueOne: 'payment_status', paramValueTwo: 'paid', barTitle: 'Paid orders',)));
}
,
),
),
const SizedBox(width: 8),
],
),
),
),
),
],
),
),
Text('My recent placed orders', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20)),
Container(
child: OrdersList(),
),
SizedBox(height: 10.0),
],
),
),
drawer: DrawerLogged()
),
);
}else{
return LoadingScreenCustom(page:'home');
}
}
);
}else{
return LoadingScreenCustom(page:'home');
}
}
);
}else{
return LoadingScreenCustom(page:'home');
}
}
);
}
}
}
I don't know if it is a good practice to add multiple stream builders on the same page.
Put String count_unpaid = snapshot2.data.length.toString(); line inside the if (snapshot2.hasData) block.
Put String count_awaiting = snapshot3.data.length.toString(); line inside the if (snapshot3.hasData) block.

How to change tab programmatically on BottomAppBar flutter?

I am working on a flutter application where I need to change my tab programmatically, here If I came on the last screen of the stack then I need to redirect to the first tab programmatically instead of closing the app.
Please consider the following code snnipet:
final PageStorageBucket bucket = PageStorageBucket();
Widget currentScreen = HomeFragment();
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Color(0xFFF3F5F9),
body: PageStorage(
child: currentScreen,
bucket: bucket,
),
bottomNavigationBar: BottomAppBar(
shape: CircularNotchedRectangle(),
child: Container(
width: double.infinity,
height: 15.5,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
GestureDetector(
onTap: () {
setState(() {
currentScreen = HomeFragment();
currentTab = 0;
});
},
child: Expanded(
child: Container(
height: 15.5,
color: Colors.white,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Image.asset(
'assets/home.png',
color: currentTab == 0 ? Color(0xFF193F70) : Color(0xFFABAAAA),
),
SizedBox(
height: 3.0,
),
Text(
'Home',
),
],
),
),
),
),
GestureDetector(
onTap: () {
setState(() {
redirectToLogin();
});
},
child: Expanded(
child: Container(
height: 15.5,
color: Colors.white,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Image.asset(
'assets/login_icon.png',
color: currentTab == 1 ? Color(0xFF193F70) : Color(0xFFABAAAA),
),
SizedBox(
height: 3.0,
),
Text(
'Login',
),
],
),
),
),
),
GestureDetector(
onTap: () {
setState(() {
redirectToSignUp();
});
},
child: Expanded(
child: Container(
height: 15.5,
color: Colors.white,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Image.asset(
'assets/signup_icon.png',
color: currentTab == 2 ? Color(0xFF193F70) : Color(0xFFABAAAA),
),
SizedBox(
height: 3.0,
),
Text(
'SignUp',
),
],
),
),
),
),
GestureDetector(
onTap: () {
setState(() {
currentScreen = ProfileFrag();
currentTab = 3;
});
},
child: Expanded(
child: Container(
height: 15.5,
color: Colors.white,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Image.asset(
'assets/menu_icon.png',
color: currentTab == 3 ? Color(0xFF193F70) : Color(0xFFABAAAA),
),
SizedBox(
height: 3.0,
),
Text(
'Menu',
),
],
),
),
),
),
],
),
),
),
);}
Here I am looking for something that can redirect to a different tab programmatically. Also please let me know if I am doing something wrong here.
I believe it would be better to use a real Flutter TabBar. Have you considered this solution?
There is a complete tutorial on this blog : https://blog.logrocket.com/flutter-tabbar-a-complete-tutorial-with-examples/
It includes a way to change tabs programmatically. This is actually what I am trying to do with my own app.
Let me know if this could work for you.

I can't set the height of my container after some limit

import 'package:flutter/material.dart';
void main() => runApp(HomePage());
class HomePage extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text("Home"),
),
body: GridView(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
),
children: [
Container(
color: Colors.blue,
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
mainAxisSize: MainAxisSize.min,
children: [
ButtonBar(
children: <Widget>[
FlatButton(
child: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Center(
child: Text(
"ljsdgnvsdnv",
textAlign: TextAlign.center,
style: TextStyle(fontSize: 18),
),
),
Text(
"sljdvnldnvsdb",
style: TextStyle(fontSize: 15),
),
],
),
height: 60,
width: 600,
color: Colors.orange,
),
onPressed: () {
print("Buton");
},
),
],
)
],
),
),
],
),
),
);
}
}
I can't set the height of my containers after some limit(also the widht of the second container), it doesn't give any errors but at the same time it doesn't change it's height. In flutter inspector their height and widht values are the values which are I assigned but it doesn't look like it. What should I do? (Text are random)
I just tried your code and didn't find any error while running it. But if the error that you are talking about are linked with the size of the container and some limit that you have added, than it's because you are trying to create an widget bigger than the zone that contain the widget.
You should check the limit that you have by trying:
mainAxisSize: MainAxisSize.max,
And than you could give value that are within the zone.

Updating part of a stateful widget

i'm very new to Flutter.
I have a stateful widget. Every time i click a counter, the whole build function runs and the results are updated.
But is there a way to make it a stateless widget and update only the relevant part somehow so i could avoid rebuilding the screen?
I have a stateful widget. Every time i click a counter, the whole build function runs and the results are updated.
But is there a way to make it a stateless widget and update only the relevant part somehow so i could avoid rebuilding the screen?
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(
home:Home(),
));
}
class Home extends StatefulWidget {
#override
_HomeState createState() => _HomeState();
}
class _HomeState extends State {
int long = 0;
void increaseCounter(){
setState(() {
long++;
});
}
void decreaseCounter(){
if(long > 0) {
setState(() {
long--;
});
}
}
Text numberOfDeliveries(){
return Text(
'$long deliveries today',
style: TextStyle(
color:Colors.white,
fontSize: 24.0,
),
);
}
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title:Text('Deliveries'),
backgroundColor: Colors.green,
),
body: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expanded(
child: Container(
color: Colors.blue,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child:Padding(
padding: const EdgeInsets.symmetric(vertical: 32.0, horizontal: 0.0),
child: Text(
'Long',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 32.0,
color: Colors.white,
),
),
),
),
Expanded(
child:
// is it possible to update this without running the whole build again?
numberOfDeliveries(),
),
Expanded(
child: Row(
children: [
Expanded(
child: Container(
padding: EdgeInsets.symmetric(vertical: 32.0, horizontal: 0.0),
color:Colors.blue[100],
child: FlatButton(
onPressed: (){
decreaseCounter();
},
child: Text('-'),
),
),
),
Expanded(
child: Container(
padding: EdgeInsets.symmetric(vertical: 32.0, horizontal: 0.0),
color:Colors.blue[500],
),
),
Expanded(
child: Container(
padding: EdgeInsets.symmetric(vertical: 32.0, horizontal: 0.0),
color:Colors.blue[900],
child: FlatButton(
onPressed: (){
increaseCounter();
},
child: Text('+'),
),
),
),
],
),
),
],
),
),
),
Expanded(
child: Container(
color: Colors.blue[800],
child: Row(
children: [
Text('Bottom'),
],
),
),
),
],
),
);
}
}