Reputation: 9830
I have a RoundedLoadingButton
in a SingleChildScrollView
. There are 2 issues.
1: the bottom of the button is cut off (see the bottom shadow)
2: When I click the button or the button becomes a loader, an error pops up on the screen.
I tried adding an Expanded
widget to the Column
and RoundedLoadingButton
, but nothing changed. I also tried changing the mainAxisSize
of the column to min and max, but they both didn't help.
What am I doing wrong and how can I fix it?
return SingleChildScrollView(
child: Container(
padding: EdgeInsets.symmetric(horizontal: 40),
child: Form(
child: Column(
children: [
SizedBox(height: Constants.verticaleSectionSpacing * 2),
TextFormField(),
TextFormField(),
TextFormField(),
RoundedLoadingButton(
height: 45,
width: double.infinity,
controller: saveBtnController,
child: Text('Save'),
onPressed: _doSomething,
),
],
),
),
),
);
Upvotes: 0
Views: 242
Reputation: 54377
You can copy paste run full code below
You can change width
from double.infinity
to MediaQuery.of(context).size.width
or a fixed number like 300
working demo
full code
import 'package:flutter/material.dart';
import 'package:rounded_loading_button/rounded_loading_button.dart';
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: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: SingleChildScrollView(
child: Container(
padding: EdgeInsets.symmetric(horizontal: 40),
child: Form(
child: Column(
children: [
//SizedBox(height: Constants.verticaleSectionSpacing * 2),
TextFormField(),
TextFormField(),
TextFormField(),
RoundedLoadingButton(
height: 45,
width: MediaQuery.of(context).size.width,
//controller: saveBtnController,
child: Text('Save'),
onPressed: () {},
),
],
),
),
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
),
);
}
}
Upvotes: 1