Incorrect use of ParentDataWidget. flutter app - flutter

i'm stuck on this problem for long time
in debug console
i don't know how to fix it please help
it says flexible while i did not use flexible widget.
i only used expanded and even when i remove expanded widget still have the same error
also i tried to remove everything except the list view builder widget i sill get the same error
this is the code:
import 'package:flutter/material.dart';
import 'package:todoy/Colors.dart';
import 'Taskslistview.dart';
import 'TasksListTile.dart';
import 'package:provider/provider.dart';
import 'Helper.dart';
bool isChekec = false;
class TasksScreen extends StatelessWidget {
Widget buildsheet(BuildContext context) {
return SingleChildScrollView(
child: Column(
children: [
Container(
decoration: BoxDecoration(
color: Colors.white,
),
height: 400,
child: Padding(
padding: EdgeInsets.only(left: 50.0, right: 50),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
SizedBox(
height: 10,
),
Center(
child: Text(
'Add Task',
style: TextStyle(
fontSize: 30,
color: Provider.of<Helper>(context).choosedcolor),
)),
TextField(
decoration: InputDecoration(
helperStyle: TextStyle(color: Colors.red),
helperText: Provider.of<Helper>(context).alreadyexist
? "this task already exist"
: " "),
textAlign: TextAlign.center,
onChanged: (value) {
if (Provider.of<Helper>(context, listen: false)
.tasknames
.contains(value)) {
Provider.of<Helper>(context, listen: false)
.alreadyture();
} else {
Provider.of<Helper>(context, listen: false)
.alreadyfalse();
}
Provider.of<Helper>(context, listen: false)
.addtaskname(value);
Provider.of<Helper>(context, listen: false)
.addtaskname(value);
print(Provider.of<Helper>(context, listen: false)
.addedtask);
},
),
SizedBox(
height: 10,
),
Container(
height: 50,
// ignore: deprecated_member_use
child: FlatButton(
color: Provider.of<Helper>(context).choosedcolor,
onPressed: () {
if (Provider.of<Helper>(context, listen: false)
.alreadyexist) {
print("you cant");
} else if (Provider.of<Helper>(context, listen: false)
.addedtask ==
"") {
print("ffgg");
} else {
Provider.of<Helper>(context, listen: false).addname(
Provider.of<Helper>(context, listen: false)
.addedtask);
Provider.of<Helper>(context, listen: false)
.add(TasksListTile(
isChcked: isChekec,
nameofthetask:
Provider.of<Helper>(context, listen: false)
.addedtask,
));
Provider.of<Helper>(context, listen: false)
.addedtask = "";
Navigator.pop(context);
}
},
child: Text(
"ADD",
style: TextStyle(color: Colors.white, fontSize: 20),
)),
)
],
),
),
),
],
),
);
}
#override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
backgroundColor: Provider.of<Helper>(context).choosedcolor,
body: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Padding(
padding: const EdgeInsets.only(left: 300.0, top: 30, right: 15),
child: GestureDetector(
onTap: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) => ColorsScreen()));
},
child: CircleAvatar(
radius: 35,
backgroundColor: Colors.white,
child: Icon(
Icons.invert_colors,
size: 40,
color: Provider.of<Helper>(context).choosedcolor,
)),
),
),
Padding(
padding: EdgeInsets.only(left: 40.0, top: 40),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.only(left: 10.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
CircleAvatar(
radius: 35,
backgroundColor: Colors.white,
child: Icon(
Icons.list,
size: 40,
color: Provider.of<Helper>(context).choosedcolor,
)),
Padding(
padding: const EdgeInsets.only(right: 30.0),
child: Container(
height: 67,
child: FittedBox(
child: FloatingActionButton(
child: Icon(Icons.delete_forever,
size: 40,
color: Provider.of<Helper>(context)
.choosedcolor),
backgroundColor: Colors.white,
onPressed: () {
Provider.of<Helper>(context, listen: false)
.remove();
},
),
),
),
),
],
),
),
Padding(
padding: EdgeInsets.only(top: 8.0, left: 10, bottom: 10),
child: Text(
"Todoy",
style: TextStyle(color: Colors.white, fontSize: 40),
textAlign: TextAlign.start,
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
' ${Provider.of<Helper>(context).tasks.length} Tasks',
style: TextStyle(color: Colors.white, fontSize: 40),
textAlign: TextAlign.start,
),
Padding(
padding: const EdgeInsets.only(right: 30.0),
child: Container(
height: 70,
child: FittedBox(
child: FloatingActionButton(
child: Text(
"+",
style: TextStyle(
fontSize: 50,
color: Provider.of<Helper>(context)
.choosedcolor),
),
backgroundColor: Colors.white,
onPressed: () {
showModalBottomSheet(
context: context, builder: buildsheet);
},
),
),
),
),
],
),
],
),
),
SizedBox(
height: 20,
),
Expanded(
child: Container(
padding: EdgeInsets.only(left: 20),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(40),
topRight: Radius.circular(40))),
child: Taskslistview(),
),
),
],
),
),
);
}
}
inside Tasklistview:
class Taskslistview extends StatelessWidget {
#override
Widget build(BuildContext context) {
bool isChecked = false;
return ListView.builder(
itemCount: Provider.of<Helper>(context).tasks.length,
itemBuilder: (context, index) {
return TasksListTile(
isChcked: isChecked,
nameofthetask:
Provider.of<Helper>(context, listen: false).tasknames[index],
);
},
);
}
}
please help i tried everything to fix it nothing worked

Related

Flutter - CupertinoPicker in an alert dialog

I am stuck right now with the little app that I am trying to create.
The user when he will tap on an icon is supposed to get an alert dialog with 2 buttons (OK and Cancel), and in the body of the alert box, a Cupertino Picker. Below you will find the code. I am getting this error message.
Failed assertion: line 85 pos 15: 'children != null': is not true.
class Engage extends StatefulWidget {
Engage ({Key key}) : super(key:key);
#override
_EngageState createState() => _EngageState();
}
class _MyEngageState extends State<MyEngage> {
#override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.all(10.0),
decoration: BoxDecoration(
border: Border.all(color: Colors.grey[350])),
child: Column(
children: [
Padding(
padding: const EdgeInsets.all(3.0),
child: Container(
// margin: const EdgeInsets.all(30.0),
padding: const EdgeInsets.all(10.0),
decoration: BoxDecoration(
border: Border.all(color: Colors.grey[350])
),
child : Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
GestureDetector(
child: Column(
children: [
IconButton(
splashColor: Colors.lightGreenAccent,
icon : Image.asset('assets/icons/icon1',
height: iconHeighEngage,),
onPressed:(){
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text('TEST'),
content: Container(
height: 350,
child: Column(
children: <Widget>[
CupertinoPicker(),
FlatButton(
child: Text("OK"),
onPressed: () {
Navigator.pop(context);
},
)
],
),
));
});
},
),
Text('TEST')],
),
),
Give it a try to this!
Padding(
padding: const EdgeInsets.all(3.0),
child: Container(
// margin: const EdgeInsets.all(30.0),
padding: const EdgeInsets.all(10.0),
decoration: BoxDecoration(
border: Border.all(color: Colors.grey[350])),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
GestureDetector(
child: Column(
children: [
IconButton(
splashColor: Colors.lightGreenAccent,
icon: Icon(
Icons.add,
),
onPressed: () {
showDialog(
context: context,
builder: (BuildContext ctx) {
return AlertDialog(
title: Text('My Titile'),
content: Container(
height: 350,
width: 350.0,
child: Column(
children: <Widget>[
CupertinoPicker(
itemExtent: 200.0,
onSelectedItemChanged:
(int value) {
print("Test");
},
children: <Widget>[
FlatButton(
child: Container(
color:
Colors.orangeAccent,
width: 350.0,
height: 160.0,
child: Center(
child: Text(
"OK",
style: TextStyle(
fontSize: 20.0),
)),
),
onPressed: () {
Navigator.pop(context);
},
)
],
),
],
),
),
);
},
);
},
),
Text('TEST')
],
),
),
],
),
),
)
Note: The problem was, you weren't passing the parameters of CupertinoPicker()
EDIT :
First Initialize
int selected = 0;
and then:
Padding(
padding: const EdgeInsets.all(3.0),
child: Container(
padding: const EdgeInsets.all(10.0),
decoration:
BoxDecoration(border: Border.all(color: Colors.grey[350])),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
GestureDetector(
child: Column(
children: [
IconButton(
splashColor: Colors.lightGreenAccent,
icon: Icon(
Icons.add,
),
onPressed: () {
showDialog(
context: context,
builder: (BuildContext ctx) {
return StatefulBuilder(
builder: (context, setState) {
return AlertDialog(
backgroundColor: Colors.lightBlueAccent,
title: Text(
'My Dialog',
style: TextStyle(
color: Colors.white,
fontSize: 30.0,
fontWeight: FontWeight.bold,
),
),
content: Container(
height: 350.0,
width: 350.0,
child: Column(
children: <Widget>[
Expanded(
child: CupertinoPicker(
useMagnifier: true,
magnification: 1.5,
backgroundColor: Colors.white,
itemExtent: 40.0,
onSelectedItemChanged: (int index) {
print(selected);
setState(() {
selected = index;
});
print(selected);
},
children: <Widget>[
Text(
"Text 1",
style: TextStyle(
color: selected == 0
? Colors.blue
: Colors.black,
fontSize: 22.0),
),
Text(
"Text 2",
style: TextStyle(
color: selected == 1
? Colors.blue
: Colors.black,
fontSize: 22.0),
),
Text(
"Text 3",
style: TextStyle(
color: selected == 2
? Colors.blue
: Colors.black,
fontSize: 22.0),
),
],
),
)
],
),
),
);
},
);
},
);
},
),
Text('Add')
],
),
),
],
),
),
),
The code is tested and working pretty fine now!

How to dynamically sort by date in flutter?

I am working on a to do list app on flutter and I will like to sort the uploaded tasks by date(new ones appear first). for doing this I think a key should be givin to each of the uploaded items in the to do list and this key should include a Date. In react native for doing this I added a function to the data in a flatlist which sorted by date but since I am new to flutter I dont know how can that be done. Any Idea helps :)
main.dart
List<String> _toDoItems = []; //this is the array in which the uploaded tasks are stored, btw Im not using any database.
TextEditingController _controller = TextEditingController();
void _addToDoItem(String task) {
if(task.length > 0) {
setState(() {
_toDoItems.add(task);
});
}
}
void _removeTodoItem(int index) {
setState(() => _toDoItems.removeAt(index));
}
Widget _buildToDoItem(String toDoText, int index) {
return SizedBox(
child: Container(
height: 58,
margin: EdgeInsets.only(left: 22.0, right: 22.0, bottom: 12,),
decoration: BoxDecoration(
border: Border.all(width: 1.5, color: Colors.red),
borderRadius: BorderRadius.all(Radius.circular(18)),
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children:[
Expanded(
child: ListTile(
title: Text(
toDoText,
style: TextStyle(fontSize: 18),
),
onTap: () => _removeTodoItem(index),
),
),
FlatButton(
child: Text('Delete', style: TextStyle(color: Colors.red, fontSize: 16.5),),
onPressed: () => _removeTodoItem(index),
),
],
),
),
);
}
Widget _buildToDoList() {
return Expanded(
child: ListView.builder(
itemBuilder: (context, index) {
if (index < _toDoItems.length) {
return _buildToDoItem(_toDoItems[index], index);
}
},
),
);
}
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: PreferredSize(
preferredSize: Size.fromHeight(50),
child: AppBar(
centerTitle: true,
backgroundColor: Colors.red,
title: Text('To Do List', style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold,),),
)
),
backgroundColor: Colors.white,
body: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
height: 60,
margin: EdgeInsets.all(22),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
flex: 10,
child: Container(
height: double.infinity,
child: TextField(
controller: _controller,
autofocus: true,
onSubmitted: (val) {
_addToDoItem(val);
_controller.clear();
},
style: TextStyle(fontSize: 18,),
),
),
),
Expanded(
flex: 4,
child: Container(
height: double.infinity,
margin: EdgeInsets.only(left: 12),
child: RaisedButton(
textColor: Colors.white,
color: Colors.red,
child: Text('ADD', style: TextStyle(fontSize: 18)),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(12)),
),
onPressed: () {
_addToDoItem(_controller.text);
_controller.clear();
FocusScope.of(context).requestFocus(FocusNode());
},
),
),
),
],
),
),
_buildToDoList()
]
),
),
);
}
You need to use the sort() method of List, also you need to be able to stock in a way or another the time of creation of your task.
I've made an example with the code you've posted. Using it your last created element will always be the first of the list.
import 'package:flutter/material.dart';
class ToDoElement {
final String task;
final DateTime timeOfCreation;
ToDoElement(this.task, this.timeOfCreation);
}
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
#override
createState() => _MyAppState();
}
class _MyAppState extends State {
TextEditingController _controller = TextEditingController();
List<ToDoElement> _toDoItems = [];
void _removeTodoItem(int index) {
setState(() => _toDoItems.removeAt(index));
}
void _addToDoItem(String task) {
if (task.isNotEmpty) {
setState(() => _toDoItems.add(ToDoElement(task, DateTime.now())));
}
}
Widget _buildToDoItem(String toDoText, int index) {
return SizedBox(
child: Container(
height: 58,
margin: EdgeInsets.only(left: 22, right: 22, bottom: 12),
decoration: BoxDecoration(
border: Border.all(width: 1.5, color: Colors.red),
borderRadius: BorderRadius.all(Radius.circular(18)),
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: ListTile(
title: Text(
toDoText,
style: TextStyle(fontSize: 18),
),
onTap: () => _removeTodoItem(index),
),
),
FlatButton(
child: Text(
'Delete',
style: TextStyle(color: Colors.red, fontSize: 16.5),
),
onPressed: () => _removeTodoItem(index),
),
],
),
),
);
}
int compareElement(ToDoElement a, ToDoElement b) =>
a.timeOfCreation.isAfter(b.timeOfCreation) ? -1 : 1;
Widget _buildToDoList() {
_toDoItems.sort(compareElement);
return Expanded(
child: ListView.builder(
itemCount: _toDoItems.length,
itemBuilder: (context, index) {
return _buildToDoItem(_toDoItems[index].task, index);
},
),
);
}
#override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: PreferredSize(
preferredSize: Size.fromHeight(50),
child: AppBar(
centerTitle: true,
backgroundColor: Colors.red,
title: Text(
'To Do List',
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
),
),
)),
backgroundColor: Colors.white,
body: Column(crossAxisAlignment: CrossAxisAlignment.center, children: [
Container(
height: 60,
margin: EdgeInsets.all(22),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
flex: 10,
child: Container(
height: double.infinity,
child: TextField(
controller: _controller,
autofocus: true,
onSubmitted: (val) {
_addToDoItem(val);
_controller.clear();
},
style: TextStyle(
fontSize: 18,
),
),
),
),
Expanded(
flex: 4,
child: Container(
height: double.infinity,
margin: EdgeInsets.only(left: 12),
child: RaisedButton(
textColor: Colors.white,
color: Colors.red,
child: Text('ADD', style: TextStyle(fontSize: 18)),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(12)),
),
onPressed: () {
_addToDoItem(_controller.text);
_controller.clear();
FocusScope.of(context).requestFocus(FocusNode());
},
),
),
),
],
),
),
_buildToDoList()
]),
),
);
}
}

flutter click tab hide under container

I am a beginner of flutter.
I am developing a flutter app.
this is my flutter app screen.
I want to hide the marked part as blue when I tap the bookmark tab bar.
I have tried several methods, but I could not achieve my goal.
I really need your helps.
I attached my whole code.
import 'package:botanic_flutter/login_page.dart';
import 'package:botanic_flutter/main.dart';
import 'package:botanic_flutter/root_page.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:botanic_flutter/custom_color_scheme.dart';
import 'package:google_sign_in/google_sign_in.dart';
class AccountPage extends StatefulWidget {
final String userUid;
AccountPage(this.userUid);
#override
_AccountPageState createState() => _AccountPageState();
}
class _AccountPageState extends State<AccountPage>
with SingleTickerProviderStateMixin {
final GoogleSignIn _googleSignIn = GoogleSignIn();
final FirebaseAuth _Auth = FirebaseAuth.instance;
FirebaseUser _currentUser;
TabController _controller;
ScrollController _scrollController;
#override
void initState() {
super.initState();
_scrollController = ScrollController();
_controller = TabController(length: 2, vsync: this);
}
#override
void dispose() {
_controller.dispose();
_scrollController.dispose();
super.dispose();
}
#override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
bottom: true,
child: DefaultTabController(
length: 2,
child: NestedScrollView(
controller: _scrollController,
headerSliverBuilder: (context, isScrolled) {
return <Widget>[
SliverList(
delegate: SliverChildListDelegate([
_detailedBody()
]),
),
SliverPersistentHeader(
pinned: true,
delegate: TabBarDelegate(
Column(
children: <Widget>[
TabBar(
unselectedLabelColor: Theme.of(context).colorScheme.greyColor,
labelColor: Theme.of(context).colorScheme.mainColor,
controller: _controller,
indicatorColor: Theme.of(context).colorScheme.mainColor,
tabs: [
Container(
height: 80,
padding: EdgeInsets.only(top: 10),
child: Tab(
icon: const Icon(Icons.home,
),
text: 'PLANTS',
),
),
Container(
height: 80,
padding: EdgeInsets.only(top: 10),
child: Tab(
icon: const Icon(Icons.bookmark_border,
),
text: 'BOOKMARK',
),
)
],
),
_bottomButtons(tabindi)
],
),
),
),
];
},
body: SizedBox(
height: MediaQuery.of(context).size.height,
child: TabBarView(
controller: _controller,
children: <Widget>[
GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
childAspectRatio: 1.0,
mainAxisSpacing: 1.0,
crossAxisSpacing: 1.0),
itemCount: notes.length,
itemBuilder: (context, index) => Card(
child: Image.network(notes[index],
fit: BoxFit.cover,
),
),
),
GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
childAspectRatio: 1.0,
mainAxisSpacing: 1.0,
crossAxisSpacing: 1.0),
itemCount: notes.length,
itemBuilder: (context, index) => Card(
child: Image.network(notes[index],
fit: BoxFit.cover,
),
),
)
],
),
),
),
),
),
);
}
Widget _detailedBody() {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.width * 3 / 4,
decoration: BoxDecoration(
image: DecorationImage(
fit: BoxFit.fill,
image: NetworkImage(
'http://www.korea.kr/newsWeb/resources/attaches/2017.08/03/3737_cp.jpg'),
),
),
),
Container(
transform: Matrix4.translationValues(0.0, -41.0, 0.0),
child: Column(
children: <Widget>[
Stack(
alignment: Alignment.center,
children: <Widget>[
SizedBox(
width: 90.0,
height: 90.0,
child: CircleAvatar(
backgroundColor: Colors.white,
),
),
SizedBox(
width: 82.0,
height: 82.0,
child: CircleAvatar(
backgroundImage: NetworkImage(
'https://steemitimages.com/DQmS1gGYmG3vL6PKh46A2r6MHxieVETW7kQ9QLo7tdV5FV2/IMG_1426.JPG')),
),
Container(
width: 90.0,
height: 90.0,
alignment: Alignment.bottomRight,
child: Stack(
alignment: Alignment.center,
children: <Widget>[
SizedBox(
width: 28.0,
height: 28.0,
child: FloatingActionButton(
onPressed: null,
backgroundColor: Colors.white,
//child: Icon(Icons.add),
),
),
SizedBox(
width: 25.0,
height: 25.0,
child: FloatingActionButton(
onPressed: null,
backgroundColor:
Theme.of(context).colorScheme.mainColor,
child: Icon(Icons.add),
),
),
],
))
],
),
Padding(padding: EdgeInsets.all(5.0)),
Text(
'nickname',
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 24.0),
),
Padding(padding: EdgeInsets.all(5.0)),
Text(
'introduce',
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15.0),
),
Padding(padding: EdgeInsets.all(9.0)),
FlatButton(
onPressed: () {
signOutWithGoogle().then((_) {
Navigator.popUntil(context, ModalRoute.withName('/'));
});
},
color: Theme.of(context).colorScheme.mainColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5.0)),
child: Text('로그아웃'),
),
Padding(padding: EdgeInsets.all(9.0)),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Column(
children: <Widget>[
Text(
'0',
textAlign: TextAlign.center,
style: TextStyle(fontSize: 16.0),
),
Text(
'식물수',
textAlign: TextAlign.center,
style: TextStyle(fontSize: 20.0),
),
],
),
Column(
children: <Widget>[
Text(
'0',
textAlign: TextAlign.center,
style: TextStyle(fontSize: 16.0),
),
Text(
'팔로워',
textAlign: TextAlign.center,
style: TextStyle(fontSize: 20.0),
),
],
),
Column(
children: <Widget>[
Text(
'0',
textAlign: TextAlign.center,
style: TextStyle(fontSize: 16.0),
),
Text(
'팔로잉',
textAlign: TextAlign.center,
style: TextStyle(fontSize: 20.0),
),
],
)
],
)
],
),
),
],
);
}
var tabindi = 0;
Widget _bottomButtons(tabindi) {
print(tabindi);
return tabindi == 0
? Container(
child: Row(
children: <Widget>[
Padding(
padding:
EdgeInsets.symmetric(vertical: 10.0, horizontal: 15.0),
child: Icon(
Icons.clear_all,
color: Colors.grey,
),
),
Container(
width: MediaQuery.of(context).size.width/3*1.4,
child: DropdownButton<String>(
isExpanded: true,
items: <String>['Foo', 'Bar'].map((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
onChanged: (_) {},
),
),
Padding(
padding:
EdgeInsets.symmetric(vertical: 10.0, horizontal: 5.0),
child: Icon(
Icons.mode_edit,
color: Colors.grey,
),
),
Padding(
padding:
EdgeInsets.symmetric(vertical: 10.0, horizontal: 1.0),
child: Icon(
Icons.delete,
color: Colors.grey,
),
),
Padding(
padding: EdgeInsets.all(4.0),
),
Container(
height: 30,
width: MediaQuery.of(context).size.width/4.5,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.mainColor,
borderRadius: BorderRadius.all(Radius.circular(20)),
boxShadow: <BoxShadow>[
BoxShadow(
color: Colors.grey.shade200,
offset: Offset(2, 4),
blurRadius: 5,
spreadRadius: 2)
],
),
child: FlatButton(
child: Text(
"+식물등록",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 13,
color: Colors.white,
),
),
onPressed: () => {
},
),
),
],
),
)
:
Container();
}
List<String> notes = [
'https://steemitimages.com/DQmS1gGYmG3vL6PKh46A2r6MHxieVETW7kQ9QLo7tdV5FV2/IMG_1426.JPG',
'https://lh3.googleusercontent.com/proxy/BKvyuWq6b5apNOqvSw3VxB-QhezYHAoX1AptJdWPl-Ktq-Efm2gotbeXFtFlkr_ZPZmpEHc2BsKTC9oFQgzBimKsf5oRtTqOGdlO3MTfwiOT54E5m-lCtt6ANOMzmhNsYMGRp9Pg1NzjwMRUWNoWX0oJEFcnFvjOj2Rr4LtZpkXyiQFO',
'https://img1.daumcdn.net/thumb/R720x0.q80/?scode=mtistory2&fname=http%3A%2F%2Fcfile28.uf.tistory.com%2Fimage%2F2343174F58DBC14C2ECB8B',
'https://steemitimages.com/DQmS1gGYmG3vL6PKh46A2r6MHxieVETW7kQ9QLo7tdV5FV2/IMG_1426.JPG',
'https://lh3.googleusercontent.com/proxy/BKvyuWq6b5apNOqvSw3VxB-QhezYHAoX1AptJdWPl-Ktq-Efm2gotbeXFtFlkr_ZPZmpEHc2BsKTC9oFQgzBimKsf5oRtTqOGdlO3MTfwiOT54E5m-lCtt6ANOMzmhNsYMGRp9Pg1NzjwMRUWNoWX0oJEFcnFvjOj2Rr4LtZpkXyiQFO',
'https://img1.daumcdn.net/thumb/R720x0.q80/?scode=mtistory2&fname=http%3A%2F%2Fcfile28.uf.tistory.com%2Fimage%2F2343174F58DBC14C2ECB8B',
'https://steemitimages.com/DQmS1gGYmG3vL6PKh46A2r6MHxieVETW7kQ9QLo7tdV5FV2/IMG_1426.JPG',
'https://lh3.googleusercontent.com/proxy/BKvyuWq6b5apNOqvSw3VxB-QhezYHAoX1AptJdWPl-Ktq-Efm2gotbeXFtFlkr_ZPZmpEHc2BsKTC9oFQgzBimKsf5oRtTqOGdlO3MTfwiOT54E5m-lCtt6ANOMzmhNsYMGRp9Pg1NzjwMRUWNoWX0oJEFcnFvjOj2Rr4LtZpkXyiQFO',
'https://img1.daumcdn.net/thumb/R720x0.q80/?scode=mtistory2&fname=http%3A%2F%2Fcfile28.uf.tistory.com%2Fimage%2F2343174F58DBC14C2ECB8B',
];
Future<void> signOutWithGoogle() async {
// Sign out with firebase
await _Auth.signOut();
// Sign out with google
await _googleSignIn.signOut();
}
}
class TabBarDelegate extends SliverPersistentHeaderDelegate {
TabBarDelegate(this._tabBar);
final Column _tabBar;
#override
double get minExtent => 130.0;
#override
double get maxExtent => 130.0;
#override
Widget build(BuildContext context, double shrinkOffset,
bool overlapsContent) {
return Container(
color: Color(0xFFFAFAFA),
height: 130.0,
child: _tabBar
);
}
#override
bool shouldRebuild(covariant TabBarDelegate oldDelegate) {
return false;
}
}
I am looking forward your answers.
Thank you!
Use Offstage widget
Offstage(
offstage: _controller.index == 1,
child: _bottomButtons(tabindi)
),
Update when tap TabBar
TabBar(onTap: (_) => setState((){}));

Duplicate GlobalKey detected in Widget Tree or Multiple Widgets used the same GlobalKey

I've tried to create form to input something from textfield to database using rest service, it worked just fine from the first try, but it got error the next time I tried, the error said there was something wrong with the GlobalkKey, so it's maybe around here.
class _DeliveryRecieverState extends State<DeliveryReciever> {
List datas;
File imagePath;
bool validasi = false;
String namaPenerima;
final _keyFormReceiver = GlobalKey<FormState>();
#override
Widget build(BuildContext context) {
datas = this.datas;
print(datas);
return DefaultTabController(
length: 1,
child: Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
bottom: TabBar(
tabs: <Widget>[
Tab(
icon: Icon(Icons.local_shipping),
text: "Bukti Delivery",
),
],
),
elevation: 0.1,
// backgroundColor: Colors.cyan[800],
flexibleSpace: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Color(0xFF17ead9), Color(0xFF6078ea)]),
),
),
title: Text(
"Delivery",
style: TextStyle(
fontFamily: "Popins-Bold",
fontSize: ScreenUtil.getInstance().setSp(46),
letterSpacing: .6,
fontWeight: FontWeight.bold,
),
),
actions: <Widget>[
],
),
body: TabBarView(
children: <Widget>[
SingleChildScrollView(
child: Padding(
padding: EdgeInsets.only(
left: 15.0, right: 15.0, top: 15.0, bottom: 15.0),
child: Column(
children: <Widget>[
Container(
width: double.infinity,
height: ScreenUtil.getInstance().setHeight(470),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8.0),
boxShadow: [
BoxShadow(
color: Colors.black12,
offset: Offset(0.0, 15.0),
blurRadius: 15.0),
BoxShadow(
color: Colors.black12,
offset: Offset(0.0, -10.0),
blurRadius: 10.0)
]),
child: Padding(
padding: EdgeInsets.only(
left: 16.0, right: 16.0, top: 16.0),
child: Form(
key: _keyFormReceiver,
autovalidate: validasi,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
"Nama Penerima",
style: TextStyle(
fontSize:
ScreenUtil.getInstance().setSp(30),
fontFamily: "Poppins-Bold",
letterSpacing: .6),
),
SizedBox(
height:
ScreenUtil.getInstance().setHeight(30),
),
TextFormField(
validator: validasiReceivername,
onSaved: (String nama) {
namaPenerima = nama;
},
decoration: InputDecoration(
hintText: "Nama Penerima",
hintStyle: TextStyle(
color: Colors.grey,
fontSize: 12.0)),
),
SizedBox(
height:
ScreenUtil.getInstance().setHeight(50),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Padding(
padding: const EdgeInsets.all(10.0),
child: RaisedButton(
elevation: 7.0,
color: Colors.green,
padding: EdgeInsets.all(20.0),
child: Text("LANJUT"),
textColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(10)),
onPressed: () {
parseData();
},
),
),
],
),
],
),
)),
),
],
),
),
),
],
),
bottomNavigationBar: Container(
height: 55.0,
child: BottomAppBar(
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Color(0xFF17ead9), Color(0xFF6078ea)]),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
IconButton(
icon: Icon(Icons.home, color: Colors.white),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => halamanUtama()),
);
},
),
IconButton(
icon: Icon(Icons.nature_people, color: Colors.white),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => UpcomingDelivery()),
);
},
),
IconButton(
icon: Icon(Icons.local_shipping, color: Colors.white),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ListDelivery()),
);
},
),
],
),
),
),
),
));
}
String validasiReceivername(String value) {
if (value.length == 0) {
//Toast.show("Password more than 4 ", context,duration: Toast.LENGTH_SHORT, gravity: Toast.CENTER);
return "Nama penerima tidak boleh kosong.";
} else {
return null;
}
}
void parseData() async {
if (_keyFormReceiver.currentState.validate()) {
_keyFormReceiver.currentState.save();
_keyFormReceiver.currentState.reset();
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => CustomerSignatureProof(
created_name: widget.created_name,
wmsorders_id: widget.wmsorders_id,
imagePath: widget.imagePath,
imageName: widget.imageName,
receiverName: namaPenerima,
upcoming_id: widget.upcoming_id,
upcoming_sku: widget.upcoming_sku,
upcoming_sak: widget.upcoming_sak,
upcoming_qty: widget.upcoming_qty,
upcoming_shipstatid: widget.upcoming_shipstatid,
upcoming_picname: widget.upcoming_picname,
upcoming_pictelp: widget.upcoming_pictelp,
upcoming_ordermultipleid: widget.upcoming_ordermultipleid,
upcoming_orderdetid: widget.upcoming_orderdetid,
upcoming_coordinatorid: widget.upcoming_coordinatorid,
upcoming_shipmentid: widget.upcoming_shipmentid)));
}
}
}
Here is the error in terminal,
Have anybody face the same probles as me, please give your guidance..

Button overlaps on textfield when keyboard is open

Here is my issue: The button should Not overlap the textfield.
Notice that I added a SingleChildScrollView(). The user can still scroll up and achieve the desired the result but I want to make it automatic:
Here is my code:
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_masked_text/flutter_masked_text.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:talking_dodo/dodo/pages/payment/credit_card.dart';
class WithdrawPage extends StatefulWidget {
#override
WithdrawPageState createState() {
return new WithdrawPageState();
}
}
class WithdrawPageState extends State<WithdrawPage> {
bool isDataAvailable = true;
int _radioValue = 0;
MaskedTextController ccMask =
MaskedTextController(mask: "0000 0000 0000 0000");
Widget _buildBody() {
return Stack(
children: <Widget>[
SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.only(
left: 16.0, right: 16.0, top: 16.0, bottom: 16.0),
child: Column(
children: <Widget>[
Row(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left: 18.0),
child: Text('Please select withdrawal method below'),
),
],
),
Container(
margin: EdgeInsets.only(top: 12.0),
child: Row(
children: <Widget>[
new Radio(
value: 0,
groupValue: _radioValue,
onChanged: ((value) {
setState(() {
_radioValue = value;
});
}),
),
Text(
'ATM Withdrawal',
),
],
),
),
Container(
height: 220.0,
padding: EdgeInsets.only(left: 20.0, right: 10.0),
margin: const EdgeInsets.all(2.0),
decoration: BoxDecoration(
// color: Colors.white,
border: Border.all(color: Colors.black),
borderRadius: BorderRadius.all(Radius.circular(12.0)),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Bullet('Visit mcb Branch'),
Bullet('Select "Dodo Wallet" in the options'),
Bullet('Select the amount to withdraw'),
Bullet('Input your dodo wallet pin'),
Bullet(
'Input the code in the input box below and click withdraw'),
Padding(
padding: const EdgeInsets.only(top:18.0),
child: TextField(
controller: ccMask,
keyboardType: TextInputType.number,
maxLength: 19,
style:
TextStyle(fontFamily: 'Raleway', color: Colors.black),
decoration: InputDecoration(
labelText: "Code",
labelStyle: TextStyle(fontWeight: FontWeight.bold),
border: OutlineInputBorder()),
),
),
],
),
),
Row(
children: <Widget>[
new Radio(
value: 1,
groupValue: _radioValue,
onChanged: ((value) {
setState(() {
_radioValue = value;
});
}),
),
Text(
'Transfer to card',
),
],
),
],
),
),
),
Align(
alignment: Alignment.bottomCenter,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
child: isDataAvailable
? Expanded(
child: ButtonTheme(
height: 65.0,
child: RaisedButton(
color: Theme.of(context).primaryColorLight,
child: Text('Withdraw funds'),
onPressed: () => showSuccessDialog()),
),
)
: Padding(
padding: EdgeInsets.only(bottom: 10.0),
child: CircularProgressIndicator()),
),
],
),
),
],
);
}
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Withdrawal"),
),
body: _buildBody(),
);
}
void showSuccessDialog() {
setState(() {
isDataAvailable = false;
Future.delayed(Duration(seconds: 1)).then((_) => goToDialog());
});
}
goToDialog() {
setState(() {
isDataAvailable = true;
});
showDialog(
context: context,
barrierDismissible: true,
builder: (context) => Center(
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
successTicket(),
SizedBox(
height: 10.0,
),
FloatingActionButton(
backgroundColor: Colors.black,
child: Icon(
Icons.clear,
color: Colors.white,
),
onPressed: () {
Navigator.pop(context);
Navigator.of(context).pushNamed('/chat');
},
)
],
),
),
));
}
successTicket() => Container(
width: double.infinity,
padding: const EdgeInsets.all(16.0),
child: Material(
clipBehavior: Clip.antiAlias,
elevation: 2.0,
borderRadius: BorderRadius.circular(4.0),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
ProfileTile(
title: "Thank You!",
textColor: Colors.purple,
subtitle: "Your transaction was successful",
),
ListTile(
title: Text("Date"),
subtitle: Text("26 June 2018"),
trailing: Text("11:00 AM"),
),
ListTile(
title: Text("Daniel Daniel"),
subtitle: Text("gmail#daniel.com"),
trailing: CircleAvatar(
radius: 20.0,
backgroundImage: NetworkImage(
"https://avatars0.githubusercontent.com/u/12619420?s=460&v=4"),
),
),
ListTile(
title: Text("Amount"),
subtitle: Text("\$423.00"),
trailing: Text("Completed"),
),
Card(
clipBehavior: Clip.antiAlias,
elevation: 0.0,
color: Colors.grey.shade300,
child: ListTile(
leading: Icon(
FontAwesomeIcons.ccAmex,
color: Colors.blue,
),
title: Text("Credit/Debit Card"),
subtitle: Text("Amex Card ending ***6"),
),
),
],
),
),
),
);
}
class Bullet extends Text {
const Bullet(
String data, {
Key key,
TextStyle style,
TextAlign textAlign,
TextDirection textDirection,
Locale locale,
bool softWrap,
TextOverflow overflow,
double textScaleFactor,
int maxLines,
String semanticsLabel,
}) : super(
'• $data',
key: key,
style: style,
textAlign: textAlign,
textDirection: textDirection,
locale: locale,
softWrap: softWrap,
overflow: overflow,
textScaleFactor: textScaleFactor,
maxLines: maxLines,
semanticsLabel: semanticsLabel,
);
}
What you're looking for is the scrollPadding parameter of textfield. Flutter automatically scrolls the view to the top of the keyboard when the textfield is focused, but it has no idea about the fact that you've placed a button that sits at the bottom of the screen.
With your current code, you could simply replace scrollPadding with padding that has a larger bottom (i.e. the size of the yellow button) and flutter should do the rest for you.