Resolve renderflex overflowed for resources list

This commit is contained in:
Thomas Fransolet 2021-05-25 19:15:56 +02:00
parent ab833808a4
commit 019402b4c0
2 changed files with 49 additions and 54 deletions

View File

@ -88,31 +88,28 @@ class _ResourceBodyGridState extends State<ResourceBodyGrid> {
) )
], ],
), ),
Container( Expanded(
height: size.height *0.85, child: GridView.builder(
child: SingleChildScrollView( shrinkWrap: true,
child: GridView.builder( gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 6),
shrinkWrap: true, itemCount: data.length,
gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 6), itemBuilder: (BuildContext context, int index) {
itemCount: data.length, return
itemBuilder: (BuildContext context, int index) { InkWell(
return onTap: () {
InkWell( widget.onSelect(resourcesToShow[index]);
onTap: () { },
widget.onSelect(resourcesToShow[index]); child: Container(
}, decoration: boxDecoration(data[index], appContext),
child: Container( padding: const EdgeInsets.all(15),
decoration: boxDecoration(data[index], appContext), margin: EdgeInsets.symmetric(vertical: 15, horizontal: 15),
padding: const EdgeInsets.all(15), child: Align(
margin: EdgeInsets.symmetric(vertical: 15, horizontal: 15), alignment: Alignment.center,
child: Align( child: getElement(data[index], size, appContext)
alignment: Alignment.center,
child: getElement(data[index], size, appContext)
),
), ),
); ),
} );
), }
), ),
), ),
], ],

View File

@ -31,39 +31,37 @@ class _ResourcesScreenState extends State<ResourcesScreen> {
final appContext = Provider.of<AppContext>(context); final appContext = Provider.of<AppContext>(context);
Size size = MediaQuery.of(context).size; Size size = MediaQuery.of(context).size;
return Container( return FutureBuilder(
child: FutureBuilder( future: getResources(widget.onGetResult, widget.isImage, appContext),
future: getResources(widget.onGetResult, widget.isImage, appContext), builder: (context, AsyncSnapshot<dynamic> snapshot) {
builder: (context, AsyncSnapshot<dynamic> snapshot) { if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.connectionState == ConnectionState.done) { var tempOutput = new List<ResourceDTO>.from(snapshot.data);
var tempOutput = new List<ResourceDTO>.from(snapshot.data); // tempOutput.add(ResourceDTO(id: null));
// tempOutput.add(ResourceDTO(id: null)); return ResourceBodyGrid(resources: tempOutput, onSelect: (value) {
return ResourceBodyGrid(resources: tempOutput, onSelect: (value) { print("result parent");
print("result parent"); print(value);
print(value); if (widget.onGetResult == null) {
if (widget.onGetResult == null) { // Main screen
// Main screen if (value.id == null) {
if (value.id == null) { showNewResource(appContext, context);
showNewResource(appContext, context);
} else {
showResource(value, appContext, context, size);
}
} else { } else {
if (value.id == null) { showResource(value, appContext, context, size);
showNewResource(appContext, context);
} else {
// Result for select modal
widget.onGetResult(value);
}
} }
},);//bodyGrid(tempOutput, size, appContext); } else {
} else if (snapshot.connectionState == ConnectionState.none) { if (value.id == null) {
return Text("No data"); showNewResource(appContext, context);
} else { } else {
return Center(child: Container(height: size.height * 0.2, child: Text('LOADING TODO FRAISE'))); // Result for select modal
} widget.onGetResult(value);
}
}
},);//bodyGrid(tempOutput, size, appContext);
} else if (snapshot.connectionState == ConnectionState.none) {
return Text("No data");
} else {
return Center(child: Container(height: size.height * 0.2, child: Text('LOADING TODO FRAISE')));
} }
), }
); );
} }
} }