I'm trying to show my data in a simple bar chart from data stored on firestore.
The full error :
The following assertion was thrown building StreamBuilder<QuerySnapshot<Object?>>(dirty, state
_StreamBuilderBaseState<QuerySnapshot<Object?>, AsyncSnapshot<QuerySnapshot<Object?>>>#50e12):
'package:login_signup/Model/sales.dart': Failed assertion: line 13 pos 16: 'map['saleVal'] !=
is not true.
import 'package:cloud_firestore/cloud_firestore.dart';
class Sales{
final int saleVal ;
final String saleYear ;
final String colorVal ;
Sales(this.saleVal,this.colorVal,this.saleYear);
Sales.fromMap(Map<String, dynamic> map)
: assert(map['saleVal'] != null),
assert(map['saleYear'] != null),
assert(map['colorVal'] != null),
saleVal = map['saleVal'],
colorVal = map['colorVal'],
saleYear=map['saleYear'];
#override
String toString() => "Record<$saleVal:$saleYear:$colorVal>";
}
And this is the page for the chart where i have to show the sales via a chart bar
import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'Model/sales.dart';
import 'package:charts_flutter/flutter.dart' as charts;
import 'rounded_button.dart';
class ChartScreen extends StatefulWidget {
#override
_ChartScreenState createState() => _ChartScreenState();
}
class _ChartScreenState extends State<ChartScreen> {
late List<charts.Series<Sales,String>> _seriesBarData;
late List<Sales> myData ;
_generateData(myData){
_seriesBarData = <charts.Series<Sales,String>>[];
_seriesBarData.add(
charts.Series(
domainFn : (Sales sales,_) => sales.saleYear.toString() ,
measureFn : (Sales sales,_) => sales.saleVal,
colorFn : (Sales sales,_) => charts.ColorUtil.fromDartColor(Color(int.parse(sales.colorVal))),
id:"Sales",
data: myData ,
labelAccessorFn: (Sales row,_) => "${row.saleYear}"
)
);
}
#override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
body: _buildBody(context),
);
}
Widget _buildBody(BuildContext context){
return StreamBuilder<QuerySnapshot>(
stream: FirebaseFirestore.instance.collection('sales').snapshots(),
builder: (context,snapshot){
children: <Widget>[
RoundedButton(
colour: Colors.lightBlueAccent,
title: 'Dashboard',
onPressed: () {
Navigator.pushNamed(context, 'charts_screen');
},
),
];
if(!snapshot.hasData){
return LinearProgressIndicator();
}
else{
List<Sales> sales = snapshot.data!.docs
.map((snapshot) => Sales.fromMap(snapshot.data() as Map<String,dynamic>))
.toList();
return _buildChart(context, sales);
}
},
);
}
Widget _buildChart(BuildContext context , List<Sales> saledata){
List<Sales> myData ;
myData = saledata;
_generateData(myData){};
return Padding(
padding: EdgeInsets.all(8.0),
child: Container(
child: Center(
child:Column(
children: <Widget>[
Text ('Sales by Year',
style:TextStyle(fontSize:24.0 , fontWeight: FontWeight.bold),
),
SizedBox(height : 10.0, ),
/*Expanded(
child: charts.BarChart(_seriesBarData,
animate : true,
animationDuration: Duration(seconds:5),
behaviors : [
new charts.DatumLegend(
entryTextStyle : charts.TextStyleSpec(color: charts.MaterialPalette.purple.shadeDefault,
fontFamily: 'Google',
fontSize:18),
)
],
),
),*/
],
),
),
),
);
}
}
Your error occures on Sales.fromMap on the assert(map['saleVal'] != null) line. So, your map['saleVal'] happens to be null. Maybe you should drop assert lines and just use null check with default values in case of null value. Like:
Sales.fromMap(Map<String, dynamic> map)
: saleVal = map['saleVal'] ?? 0, // default value in case of null
colorVal = map['colorVal'] ?? '',
saleYear = map['saleYear'] ?? '';
Or maybe make your properties nullable, like:
final int? saleVal;
final String? saleYear;
final String? colorVal;
Related
I'm trying to create a chart on a Flutter web app by accessing data from Cloud Firestore.
However, it can't seem to extract and map the details from Firestore.
Firebase console
main.dart
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
home: Home(),
);
}
}
home.dart
import 'package:flutter/material.dart';
import 'package:firebase_database/firebase_database.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:inglesy/items.dart';
import 'package:charts_flutter/flutter.dart' as charts;
class Home extends StatefulWidget {
#override
State<Home> createState() => _HomeState();
}
class _HomeState extends State<Home> {
List<charts.Series<Item, String>>? _seriesBarData; //Try (dynamic,String)
List<Item>? myData;
_generateData(myData) {
print("_generateData worked");
_seriesBarData?.add(
charts.Series(
domainFn: (Item item, _) => item.itemstring.toString(),
measureFn: (Item item, _) => item.itemvotes,
id: 'Items',
data: myData,
),
);
}
#override
Widget build(BuildContext context) {
print("returning AppBar/scaffold now");
return Scaffold(
appBar: AppBar(
title: const Text("This is a title."),
foregroundColor: Colors.pink,
),
body: _buildBody(context),
);
}
Widget _buildBody(context) {
print("Doing _buildBody now");
final Stream<QuerySnapshot> _userStream =
FirebaseFirestore.instance.collection("poll").snapshots();
return StreamBuilder<QuerySnapshot>(
stream: _userStream,
builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
if (snapshot.hasError) {
return Text('Something went wrong');
} else {
List<Item> item = snapshot.data!.docs
.map((DocumentSnapshot document) =>
Item.fromMap(document.data() as Map<String, dynamic>))
.toList();
return _buildChart(context, item);
}
},
);
}
Widget _buildChart(BuildContext context, List<Item> item) {
myData = item;
_generateData(myData);
return Padding(
padding: EdgeInsets.all(8.0),
child: Container(
child: Center(
child: Column(
children: [
Text("This is a text"),
SizedBox(height: 10.0),
Expanded(
child: charts.BarChart(
_seriesBarData!,
animate: true,
animationDuration: const Duration(seconds: 2),
),
)
],
),
),
),
);
}
}
items.dart
class Item {
final String? itemstring;
final int? itemvotes;
Item({this.itemstring, this.itemvotes});
Item.fromMap(Map<String, dynamic> map)
: assert(map['itemstring'] != null),
assert(map['itemvotes'] != null),
itemstring = map['itemstring'],
itemvotes = map['itemvotes'];
#override
String toString() {
return "Item string: $itemstring | Item votes: $itemvotes";
}
}
It shows this error
PS, I've already done the necessary set-up i.e. I've already installed Firebase CLI and have it generated firbase_options.dart
PPS, I have also already set up Firebase (anonymous) authentication and it works with no errors. But for now, I'm not using it and I'm automatically running home.dart to focus on the Firebase database aspect.
Why don’t you try making the Item.fromMap method a regular factory method like:
factory Item.fromMap(Map<String, dynamic> map) {
return Item(
itemstring = map['itemstring'] ?? '',
itemvotes = map['itemvotes'] ?? ''
);
}
I am unable to assign my one class to another even though I have imported the lib for them. I am following a course . In this I will fetch the orders from firebase and showing the orderscreen.
Orderscreen(where i am getting the error):
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../providers/orders.dart' show Orders;
import '../widgets/app_drawer.dart';
import 'package:shop_app/Widgets/OrderItem.dart';
class OrdersScreen extends StatelessWidget {
static const routeName = '/orders';
#override
Widget build(BuildContext context) {
print('building orders');
// final orderData = Provider.of<Orders>(context);
return Scaffold(
appBar: AppBar(
title: Text('Your Orders'),
),
drawer: AppDrawer(),
body: FutureBuilder(
future: Provider.of<Orders>(context, listen: false).fetchandSetOrders(),
builder: (ctx, dataSnapshot) {
if (dataSnapshot.connectionState == ConnectionState.waiting) {
return Center(child: CircularProgressIndicator());
} else {
if (dataSnapshot.error != null) {
// ...
// Do error handling stuff
return Center(
child: Text('An error occurred!'),
);
} else {
return Consumer<Orders>(
builder: (ctx, orderData, child) => ListView.builder(
itemCount: orderData.orders.length,
itemBuilder: (ctx, i) => OrderItem(orderData.orders[i])//getting error here
),
);
}
}
},
),
);
}
}
My orderitem class :
class OrderItem extends StatefulWidget {
final ord.OrderItem order;
OrderItem(this.order);
#override
State<OrderItem> createState() => _OrderItemState();
}
class _OrderItemState extends State<OrderItem> {
var _expanded = false;
#override
Widget build(BuildContext context) {
return Card(
margin: EdgeInsets.all(10),
child: Column(
children: [
ListTile(
title: Text('\$${widget.order.amount}'),
subtitle: Text(
DateFormat('dd/MM/yyyy/ hh:mm').format(widget.order.dateTime),
),
trailing: IconButton(
icon: Icon(_expanded
? Icons.expand_less_rounded
: Icons.expand_more_rounded),
onPressed: () {
setState(() {
_expanded = !_expanded;
});
},
)),
if (_expanded)
Container(
height: min(widget.order.products.length * 20.0 + 100, 180),
child: ListView(
children: widget.order.products
.map((prod) => Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(prod.title),
Text('${prod.quanitity}x \$${prod.price}')
],
))
.toList()
//min function will give min of two functions , if expanded is true then this will take place
,
),
),
],
),
);
}
}
My orders class:
class OrderItem {
final String id;
final double amount;
final List<CartItem> products;
final DateTime dateTime;
OrderItem(this.id, this.amount, this.products, this.dateTime);
}
class Orders with ChangeNotifier {
List<OrderItem> _orders = [];
List<OrderItem> get orders {
return [..._orders];
}}
Thanks guys for all your help. it would be helpful if you can explain why i got this error as I am a novice to flutter
ide ss
Your widgets file name and data class name are same.It has same class name.Make data class name and widgets name different.It will solve the issue
Change the file name and widget name is working
Plugin Use:
provider: ^6.0.2
OrdersScreen (Order_screen.dart)
import 'package:flutter/material.dart';
import 'package:order_item_proj/OrderItem.dart';
import 'package:order_item_proj/Orders.dart' show Orders;
import 'package:provider/provider.dart';
class OrdersScreen extends StatelessWidget {
static const routeName = '/orders';
#override
Widget build(BuildContext context) {
print('building orders');
// final orderData = Provider.of<Orders>(context);
return Scaffold(
appBar: AppBar(
title: Text('Your Orders'),
),
body: FutureBuilder(
future: Provider.of<Orders>(context, listen: false).fetchandSetOrders(),
builder: (ctx, dataSnapshot) {
if (dataSnapshot.connectionState == ConnectionState.waiting) {
return Center(child: CircularProgressIndicator());
} else {
if (dataSnapshot.error != null) {
// ...
// Do error handling stuff
return Center(
child: Text('An error occurred!'),
);
} else {
return Consumer<Orders>(
builder: (ctx, orderData, child) =>
ListView.builder(itemCount: orderData.orders.length, itemBuilder: (ctx, i) => OrderItemWidget(orderData.orders[i])),
);
}
}
},
),
);
}
}
OrderItem Widget (OrderItem.dart)
import 'package:flutter/material.dart';
import 'package:order_item_proj/Orders.dart' as ord;
class OrderItemWidget extends StatefulWidget {
final ord.OrderItem order;
OrderItemWidget(this.order);
#override
State<OrderItemWidget> createState() => _OrderItemWidgetState();
}
class _OrderItemWidgetState extends State<OrderItemWidget> {
var _expanded = false;
#override
Widget build(BuildContext context) {
return Card(
margin: EdgeInsets.all(10),
child: Column(
children: [
ListTile(
title: Text('\$${widget.order.amount}'),
subtitle: Text(""),
trailing: IconButton(
icon: Icon(_expanded ? Icons.expand_less_rounded : Icons.expand_more_rounded),
onPressed: () {
setState(() {
_expanded = !_expanded;
});
},
)),
if (_expanded)
Container(
child: ListView(
children: widget.order.products
.map((prod) => Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text("title"),
],
))
.toList()
//min function will give min of two functions , if expanded is true then this will take place
,
),
),
],
),
);
}
}
OrderItem Class (Orders.dart)
import 'package:flutter/cupertino.dart';
class OrderItem {
final String id;
final double amount;
final List<String> products;
final DateTime dateTime;
OrderItem(this.id, this.amount, this.products, this.dateTime);
}
class Orders with ChangeNotifier {
List<OrderItem> _orders = [];
List<OrderItem> get orders {
return [..._orders];
}
fetchandSetOrders() {}
}
Flutter Error: Null check operator used on a null value in a StreamBuilder
no matter what i do i keep getting this error instead of the user data that i want,
in the database.dart i didn't put any ! or ? so i guess the problem's from this file, but i have no clue how to fix it.
i also tried all the commands i found on google but none of them works
class SettingsForm extends StatefulWidget {
const SettingsForm({Key? key}) : super(key: key);
#override
_SettingsFormState createState() => _SettingsFormState();
}
class _SettingsFormState extends State<SettingsForm> {
final _formKey = GlobalKey<FormState>();
final List<String> sugars = ['0','1','2','3','4'];
String?_currentName ;
String?_currentSugars ;
dynamic _currentStrength =1;
#override
Widget build(BuildContext context) {
final user = Provider.of<myUser?>(context);
return StreamBuilder<myUserData?>(
stream: DatabaseService(uid: user!.uid).userData,
builder: (context, snapshot) {
if(snapshot.hasData) {
myUserData? usdata = snapshot.data;
return Form(
key:_formKey,
child: Column(
children: [
Text('Update your brew settings.',
style: TextStyle(fontSize:18.0),),
SizedBox(height: 20,),
TextFormField(
initialValue: usdata?.name,
decoration: textInputDecoration.copyWith(hintText: ' name'),
validator: (val) => val!.isEmpty ? 'Please enter a name' : null,
onChanged: (val) {
setState(() => _currentName = val);
},
),
SizedBox(height: 20.0,),
//dropdown
DropdownButtonFormField<String>(
value: usdata?.sugars,
items: sugars.map((sugar){
return DropdownMenuItem(
value: sugar,
child: Text(' $sugar sugars')
);
}).toList(),
onChanged: (val) => setState(() => _currentSugars = val.toString()),
),
SizedBox(height:20 ),
//slider
Slider(
value: (_currentStrength ?? usdata?.strength).toDouble(),
activeColor: Colors.brown[_currentStrength ?? usdata?.strength],
inactiveColor: Colors.brown[_currentStrength ?? usdata?.strength],
min:100,
max:900,
divisions: 8,
onChanged: (val) => setState(() {
_currentStrength = val.round();
}),
),
RaisedButton(
color:Colors.pink[400],
child: Text('Update',
style: TextStyle(color:Colors.white),),
onPressed: () async {
print(_currentName);
print(_currentSugars);
print(_currentStrength);
})
],
),
);
}
else {
myUserData usdata = snapshot.data!;
print(usdata.name);
print(usdata.sugars);
print(usdata.strength);
return Container();
}
}
);
}
}
Here is a simplification of your code:
builder: (context, snapshot) {
if(snapshot.hasData) {
...
} else {
myUserData usdata = snapshot.data!;
print(usdata.name);
print(usdata.sugars);
print(usdata.strength);
return Container();
}
},
The code in your else statement will only run if snapshot.hasData is false, which means that snapshot.data is null, giving you an error when you try to read it.
Here in firestore I want to update list with new values entered by the user and to remove all previous values. Suppose user add 2 new values [American English, French]. What I want is to remove all the values in the list and update the list with these values. I have used set and update method and it is just adding new values in newer index but not removing previous.
here is my code.
addCategoriesAndSkillsInDB({List categories, List skills}) async {
print('$skills');
categories == null
? _firestore
.collection('users')
.doc(getCurrentUser().uid)
.set({'skills': skills})
: _firestore
.collection('users')
.doc(getCurrentUser().uid)
.update({'categories': FieldValue.arrayUnion(categories)});
}
and that is how I am retaining new values in the list
import 'file:///E:/flutterProject/filmmaker/lib/auth_screens/signUp_screens/worker/signUp_screen5.dart';
import 'package:filmmaker/auth_screens/signUp_screens/worker/signUp_screen14.dart';
import 'package:filmmaker/logic/bloc/fields/fields_bloc.dart';
import 'package:filmmaker/resources/repo/firebase_repo.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
class SignUpScreen4 extends StatefulWidget {
bool edit = false;
SignUpScreen4([this.edit]);
#override
_SignUpScreen4State createState() => _SignUpScreen4State();
}
class _SignUpScreen4State extends State<SignUpScreen4> {
List<String> _dynamicChips = [];
String _value;
final key = GlobalKey<FormState>();
final controller = TextEditingController();
#override
void dispose() {
// TODO: implement dispose
super.dispose();
controller.dispose();
}
#override
Widget build(BuildContext context) {
return Scaffold(
body: Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('Sign Up Screen 4'),
Form(
key: key,
child: TextFormField(
controller: controller,
validator: (value) =>
value.trim().isEmpty || value == null ? 'Empty Text' : null,
autofocus: true,
autocorrect: true,
enableSuggestions: true,
decoration: InputDecoration(
hintText:
'Type things like: Final Cut Pro, or Documentary making',
hintStyle: TextStyle(fontStyle: FontStyle.italic),
labelText: 'Tell us about some of your skills',
),
),
),
MaterialButton(
onPressed: () {
if (key.currentState.validate()) {
if (!_dynamicChips.contains(controller?.text)) {
setState(() {
_value = controller?.text;
});
_dynamicChips.add(_value);
controller.text = '';
}
}
},
child: Text("Add"),
),
dynamicChips(),
BlocConsumer<FieldsBloc, FieldsState>(builder: (context, state) {
if (state is FieldsInitial) {
return Container();
} else if (state is FieldSuccessfulState) {
return Container();
} else if (state is FieldUnsuccessfulState) {
return Padding(
padding: const EdgeInsets.all(15.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.error,
color: Colors.red,
),
SizedBox(
width: 5.0,
),
Text(
state.message,
style: TextStyle(color: Colors.red),
),
],
));
}
return Container();
}, listener: (context, state) {
if (state is FieldSuccessfulState)
widget.edit
? Navigator.of(context).push(
MaterialPageRoute(builder: (_) => SignUpScreen14()))
: Navigator.of(context).push(
MaterialPageRoute(builder: (_) => SignUpScreen5()));
}),
ElevatedButton(
onPressed: () {
BlocProvider.of<FieldsBloc>(context)
.add(NextButtonEventScreen4(_dynamicChips));
},
child: Text('Next'))
],
),
),
);
}
dynamicChips() {
return Wrap(
spacing: 6.0,
runSpacing: 6.0,
children: List<Widget>.generate(
_dynamicChips?.length,
(int index) => Chip(
label: Text(_dynamicChips[index]),
onDeleted: () {
setState(() {
_dynamicChips.removeAt(index);
});
},
)),
);
}
}
You need to pass List instead of String. For example
List<String> languages = ['English', 'Nepali', 'hindi'];
and then,
_firestore
.collection('users')
.doc(getCurrentUser().uid)
.update({'other languages': languages});
I'm using a method of searching for an api but I'm not managing to pass the information I get to the Widget that renders it and get the data I all well
Header search Widget:
import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:movies/Movies/bloc/blocmovies.dart';
import 'package:movies/Movies/model/findmoviemodel.dart';
import 'package:movies/Movies/ui/widgets/gridview_search_screen.dart';
class HeaderSearchScreen extends StatefulWidget with PreferredSizeWidget {
HeaderSearchScreen({Key key}) : super(key: key);
#override
_HeaderSearchScreenState createState() => _HeaderSearchScreenState();
#override
Size get preferredSize => Size.fromHeight(kToolbarHeight);
}
class _HeaderSearchScreenState extends State<HeaderSearchScreen> {
BlocMovies blocMovies;
final TextEditingController _controller = TextEditingController();
Widget appBarTitle() {
return TextField(
onSubmitted: searchOperation,
autofocus: true,
controller: _controller,
style: TextStyle(
color: Colors.black,
),
decoration: InputDecoration(
suffix: IconButton(
icon: Icon(Icons.cancel),
onPressed: () {
Future.delayed(Duration(milliseconds: 50)).then((_) {
_controller.clear();
FocusScope.of(context).unfocus();
});
},
),
hintText: "Buscar",
hintStyle: TextStyle(color: Colors.grey.withOpacity(0.5))),
);
}
#override
Widget build(BuildContext context) {
blocMovies = BlocProvider.of(context);
return buildAppBar(context);
}
Widget buildAppBar(BuildContext context) {
return AppBar(
iconTheme: IconThemeData(color: Colors.black),
backgroundColor: Colors.white,
centerTitle: true,
title: this.appBarTitle());
}
searchOperation(String searchText) {
blocMovies.findMovies(searchText)
.then((data){
if(data.results.length == 0){
print("no se encontro");
showDialog(
context: context,
child: AlertDialog(
title: const Text("No se encontro la pelicula"),
actions: [
FlatButton(
child: const Text("Ok"),
onPressed: () => Navigator.pop(context),
),
],
),
);
}else{
setState(() {
print(data.results);
GridViewSearchScreen(listsearchmovieOne: data.results);
});
}
})
.catchError((){
print("Hubo un error");
});
}
}
/*
blocMovies.findMovies(searchText)
.then((data){
if(data.results.length == 0){
print("no se encontro");
showDialog(
context: context,
child: AlertDialog(
title: const Text("No se encontro la pelicula"),
actions: [
FlatButton(
child: const Text("Ok"),
onPressed: () => Navigator.pop(context),
),
],
),
);
}else{
//Here trying pass datan and debug console a get snapshot
GridViewSearchScreen(listsearchmovieOne: data.results);
}
})
.catchError((){
print("Hubo un error");
});
GridViewSearch:
import 'package:animate_do/animate_do.dart';
import 'package:flutter/material.dart';
import 'package:movies/Movies/model/findmoviemodel.dart';
import 'package:movies/Movies/ui/widgets/cadsearchmovies.dart';
import 'package:movies/Widgets/Screen_Sizes/responsive_screens.dart';
class GridViewSearchScreen extends StatefulWidget {
List<Result> listsearchmovieOne;
double _crossAxisSpacing = 15, _mainAxisSpacing = 12, _aspectRatio = 1;
GridViewSearchScreen({Key key, this.listsearchmovieOne}) : super(key: key);
#override
_GridViewSearchScreenState createState() => _GridViewSearchScreenState(listsearchmovie: this.listsearchmovieOne );
}
class _GridViewSearchScreenState extends State<GridViewSearchScreen> {
List<Result> listsearchmovie;
_GridViewSearchScreenState({this.listsearchmovie});
#override
Widget build(BuildContext context) {
double screenWidth = MediaQuery.of(context).size.width;
double screenHeight = MediaQuery.of(context).size.height;
double _pixeRatio = MediaQuery.of(context).devicePixelRatio;
bool small = ResponsiveWidget.isScreenSmall(screenWidth, _pixeRatio);
bool medium = ResponsiveWidget.isScreenMedium(screenWidth, _pixeRatio);
bool large = ResponsiveWidget.isScreenLarge(screenWidth, _pixeRatio);
return (listsearchmovie == null)
? Center(
child: Container(
child: Text("No hay peliculas que mostrar"),
))
: Container(
margin: EdgeInsets.only(top: screenHeight * 0.2),
child: GridView.builder(
itemCount: listsearchmovie.length,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: (large) ? 4 : (medium) ? 2 : (small) ? 2 : 2,
crossAxisSpacing: widget._crossAxisSpacing,
mainAxisSpacing: widget._mainAxisSpacing,
childAspectRatio: (large)
? screenWidth / (screenHeight / 0.62)
: (medium)
? screenWidth / (screenHeight / 1.03)
: (small)
? screenWidth / (screenHeight / 1.03)
: screenWidth / (screenHeight / 1.03),
),
itemBuilder: (BuildContext context, int i) {
final movie = listsearchmovie[i];
print(movie.posterPath);
return FadeInLeft(
duration: Duration(milliseconds: 10 * i),
child: CardSearchinfoMovies(
movie: Result(
backdropPath: movie.backdropPath,
overview: movie.overview,
posterPath: movie.posterPath,
voteAverage: movie.voteAverage,
title: movie.title)),
);
}));
}
}
and on this screen is where together these two widgets
import 'package:flutter/material.dart';
import 'package:movies/Movies/ui/widgets/gridview_search_screen.dart';
import 'package:movies/Movies/ui/widgets/header_search_screen.dart';
class ScreenSearchMovies extends StatefulWidget {
#override
_ScreenSearchMoviesState createState() => _ScreenSearchMoviesState();
}
class _ScreenSearchMoviesState extends State<ScreenSearchMovies> {
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: HeaderSearchScreen(),
body: Stack(
children:<Widget>[
GridViewSearchScreen()
]
)
);
}
}
Any idea what might be going on already trying everything and I can't get the information displayed?
Try this way:
`....
....
class _GridViewSearchScreenState extends State<GridViewSearchScreen> {
List<Result> listsearchmovie = List<Result>();
_GridViewSearchScreenState({this.listsearchmovie});
.....
.....
`