Can´t pass null variable between two pages in flutter
up vote
0
down vote
favorite
I´m trying to navigate between two pages. In second page I need a constructor so i need to declare the variable null in first page and initialize it in the second page.
In main.dart (first page) i have similar to
PostDetailsPage.tag: (context) => PostDetailsPage(new List()),
In the second page (PostDetailsPage) i have this
final List<charts.Series> seriesList;
final bool animate;
PostDetailsPage(this.seriesList, {this.animate});
When i go to page two return
< List < Series< dynamic, dynamic > > is not a subtype of type < List < Series< dynamic, String>>
So how can i solve? Initializate the value in first page and pass it? Initializate value as null in first page and pass it?
UPDATED
Main.dart class
import 'package:flutter/material.dart';
import 'package:fluttercrud/screens/login_page.dart';
import 'package:fluttercrud/screens/home_page.dart';
import 'package:fluttercrud/screens/partials/list_post.dart';
import 'package:fluttercrud/screens/maps_page.dart';
import 'package:fluttercrud/screens/post_details_page.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
final routes = <String, WidgetBuilder>{
LoginPage.tag: (context) => LoginPage(),
HomePage.tag: (context) => HomePage(),
ListPost.tag: (context) => ListPost(),
MapsPage.tag: (context) => MapsPage(),
PostDetailsPage.tag: (context) => PostDetailsPage(new List()),
};
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'iGota',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch : Colors.blue,
),
home: LoginPage(),
routes: routes,
);
}
}
PostDetailsPage.dart class
import 'package:flutter/material.dart';
import 'package:charts_flutter/flutter.dart' as charts;
class PostDetailsPage extends StatelessWidget{
static String tag = 'post-details-page';
final List<charts.Series> seriesList;
final bool animate;
PostDetailsPage(this.seriesList, {this.animate});
/// Creates a [BarChart] with sample data and no transition.
factory PostDetailsPage.withSampleData() {
return new PostDetailsPage(
_createSampleData(),
// Disable animations for image tests.
animate: false,
);
}
@override
Widget build(BuildContext context) {
return new charts.BarChart(
seriesList,
animate: animate,
);
}
/// Create one series with sample hard coded data.
static List<charts.Series<OrdinalSales, String>> _createSampleData() {
final data = [
new OrdinalSales('2014', 5),
new OrdinalSales('2015', 25),
new OrdinalSales('2016', 100),
new OrdinalSales('2017', 75),
];
return [
new charts.Series<OrdinalSales, String>(
id: 'Sales',
colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault,
domainFn: (OrdinalSales sales, _) => sales.year,
measureFn: (OrdinalSales sales, _) => sales.sales,
data: data,
)
];
}
}
/// Sample ordinal data type.
class OrdinalSales {
final String year;
final int sales;
OrdinalSales(this.year, this.sales);
}
UPDATED 2: FIXED
Main.dart
import 'package:flutter/material.dart';
import 'package:fluttercrud/screens/login_page.dart';
import 'package:fluttercrud/screens/home_page.dart';
import 'package:fluttercrud/screens/partials/list_post.dart';
import 'package:fluttercrud/screens/maps_page.dart';
import 'package:fluttercrud/screens/post_details_page.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
final routes = <String, WidgetBuilder>{
LoginPage.tag: (context) => LoginPage(),
HomePage.tag: (context) => HomePage(),
ListPost.tag: (context) => ListPost(),
MapsPage.tag: (context) => MapsPage(),
PostDetailsPage.tag: (context) => PostDetailsPage(),
};
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'iGota',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch : Colors.blue,
),
home: LoginPage(),
routes: routes,
);
}
}
PostDetailsPage.dart
import 'package:flutter/material.dart';
import 'package:charts_flutter/flutter.dart' as charts;
class PostDetailsPage extends StatefulWidget {
static String tag = 'post-details-page';
@override
PostDetailsPageState createState() => new PostDetailsPageState();
}
class PostDetailsPageState extends State<PostDetailsPage> {
List<charts.Series> seriesList = ;
bool animate;
void initState() {
super.initState();
seriesList = _createSampleData();
animate = false;
}
@override
Widget build(BuildContext context) {
return new Container(
decoration: new BoxDecoration(color: Colors.white),
child: new charts.BarChart(
seriesList,
animate: animate,
),
);
}
/// Create one series with sample hard coded data.
static List<charts.Series<OrdinalSales, String>> _createSampleData() {
final data = [
new OrdinalSales('2014', 5),
new OrdinalSales('2015', 25),
new OrdinalSales('2016', 100),
new OrdinalSales('2017', 75),
];
return [
new charts.Series<OrdinalSales, String>(
id: 'Sales',
colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault,
domainFn: (OrdinalSales sales, _) => sales.year,
measureFn: (OrdinalSales sales, _) => sales.sales,
data: data,
)
];
}
}
/// Sample ordinal data type.
class OrdinalSales {
final String year;
final int sales;
OrdinalSales(this.year, this.sales);
}
dart flutter
add a comment |
up vote
0
down vote
favorite
I´m trying to navigate between two pages. In second page I need a constructor so i need to declare the variable null in first page and initialize it in the second page.
In main.dart (first page) i have similar to
PostDetailsPage.tag: (context) => PostDetailsPage(new List()),
In the second page (PostDetailsPage) i have this
final List<charts.Series> seriesList;
final bool animate;
PostDetailsPage(this.seriesList, {this.animate});
When i go to page two return
< List < Series< dynamic, dynamic > > is not a subtype of type < List < Series< dynamic, String>>
So how can i solve? Initializate the value in first page and pass it? Initializate value as null in first page and pass it?
UPDATED
Main.dart class
import 'package:flutter/material.dart';
import 'package:fluttercrud/screens/login_page.dart';
import 'package:fluttercrud/screens/home_page.dart';
import 'package:fluttercrud/screens/partials/list_post.dart';
import 'package:fluttercrud/screens/maps_page.dart';
import 'package:fluttercrud/screens/post_details_page.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
final routes = <String, WidgetBuilder>{
LoginPage.tag: (context) => LoginPage(),
HomePage.tag: (context) => HomePage(),
ListPost.tag: (context) => ListPost(),
MapsPage.tag: (context) => MapsPage(),
PostDetailsPage.tag: (context) => PostDetailsPage(new List()),
};
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'iGota',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch : Colors.blue,
),
home: LoginPage(),
routes: routes,
);
}
}
PostDetailsPage.dart class
import 'package:flutter/material.dart';
import 'package:charts_flutter/flutter.dart' as charts;
class PostDetailsPage extends StatelessWidget{
static String tag = 'post-details-page';
final List<charts.Series> seriesList;
final bool animate;
PostDetailsPage(this.seriesList, {this.animate});
/// Creates a [BarChart] with sample data and no transition.
factory PostDetailsPage.withSampleData() {
return new PostDetailsPage(
_createSampleData(),
// Disable animations for image tests.
animate: false,
);
}
@override
Widget build(BuildContext context) {
return new charts.BarChart(
seriesList,
animate: animate,
);
}
/// Create one series with sample hard coded data.
static List<charts.Series<OrdinalSales, String>> _createSampleData() {
final data = [
new OrdinalSales('2014', 5),
new OrdinalSales('2015', 25),
new OrdinalSales('2016', 100),
new OrdinalSales('2017', 75),
];
return [
new charts.Series<OrdinalSales, String>(
id: 'Sales',
colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault,
domainFn: (OrdinalSales sales, _) => sales.year,
measureFn: (OrdinalSales sales, _) => sales.sales,
data: data,
)
];
}
}
/// Sample ordinal data type.
class OrdinalSales {
final String year;
final int sales;
OrdinalSales(this.year, this.sales);
}
UPDATED 2: FIXED
Main.dart
import 'package:flutter/material.dart';
import 'package:fluttercrud/screens/login_page.dart';
import 'package:fluttercrud/screens/home_page.dart';
import 'package:fluttercrud/screens/partials/list_post.dart';
import 'package:fluttercrud/screens/maps_page.dart';
import 'package:fluttercrud/screens/post_details_page.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
final routes = <String, WidgetBuilder>{
LoginPage.tag: (context) => LoginPage(),
HomePage.tag: (context) => HomePage(),
ListPost.tag: (context) => ListPost(),
MapsPage.tag: (context) => MapsPage(),
PostDetailsPage.tag: (context) => PostDetailsPage(),
};
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'iGota',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch : Colors.blue,
),
home: LoginPage(),
routes: routes,
);
}
}
PostDetailsPage.dart
import 'package:flutter/material.dart';
import 'package:charts_flutter/flutter.dart' as charts;
class PostDetailsPage extends StatefulWidget {
static String tag = 'post-details-page';
@override
PostDetailsPageState createState() => new PostDetailsPageState();
}
class PostDetailsPageState extends State<PostDetailsPage> {
List<charts.Series> seriesList = ;
bool animate;
void initState() {
super.initState();
seriesList = _createSampleData();
animate = false;
}
@override
Widget build(BuildContext context) {
return new Container(
decoration: new BoxDecoration(color: Colors.white),
child: new charts.BarChart(
seriesList,
animate: animate,
),
);
}
/// Create one series with sample hard coded data.
static List<charts.Series<OrdinalSales, String>> _createSampleData() {
final data = [
new OrdinalSales('2014', 5),
new OrdinalSales('2015', 25),
new OrdinalSales('2016', 100),
new OrdinalSales('2017', 75),
];
return [
new charts.Series<OrdinalSales, String>(
id: 'Sales',
colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault,
domainFn: (OrdinalSales sales, _) => sales.year,
measureFn: (OrdinalSales sales, _) => sales.sales,
data: data,
)
];
}
}
/// Sample ordinal data type.
class OrdinalSales {
final String year;
final int sales;
OrdinalSales(this.year, this.sales);
}
dart flutter
post the real code, what are you passing as an argument forPostDetailsPage
because the problem is just in the types you need to be explicit about them
– Raouf Rahiche
Nov 9 at 15:52
Updated with all code.
– El Hombre Sin Nombre
Nov 9 at 16:21
you are passing an invalid listnew List()
toPostDetailsPage
so you need to provide a real list as an argument
– Raouf Rahiche
Nov 9 at 16:30
Can you put a example?
– El Hombre Sin Nombre
Nov 9 at 16:46
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I´m trying to navigate between two pages. In second page I need a constructor so i need to declare the variable null in first page and initialize it in the second page.
In main.dart (first page) i have similar to
PostDetailsPage.tag: (context) => PostDetailsPage(new List()),
In the second page (PostDetailsPage) i have this
final List<charts.Series> seriesList;
final bool animate;
PostDetailsPage(this.seriesList, {this.animate});
When i go to page two return
< List < Series< dynamic, dynamic > > is not a subtype of type < List < Series< dynamic, String>>
So how can i solve? Initializate the value in first page and pass it? Initializate value as null in first page and pass it?
UPDATED
Main.dart class
import 'package:flutter/material.dart';
import 'package:fluttercrud/screens/login_page.dart';
import 'package:fluttercrud/screens/home_page.dart';
import 'package:fluttercrud/screens/partials/list_post.dart';
import 'package:fluttercrud/screens/maps_page.dart';
import 'package:fluttercrud/screens/post_details_page.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
final routes = <String, WidgetBuilder>{
LoginPage.tag: (context) => LoginPage(),
HomePage.tag: (context) => HomePage(),
ListPost.tag: (context) => ListPost(),
MapsPage.tag: (context) => MapsPage(),
PostDetailsPage.tag: (context) => PostDetailsPage(new List()),
};
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'iGota',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch : Colors.blue,
),
home: LoginPage(),
routes: routes,
);
}
}
PostDetailsPage.dart class
import 'package:flutter/material.dart';
import 'package:charts_flutter/flutter.dart' as charts;
class PostDetailsPage extends StatelessWidget{
static String tag = 'post-details-page';
final List<charts.Series> seriesList;
final bool animate;
PostDetailsPage(this.seriesList, {this.animate});
/// Creates a [BarChart] with sample data and no transition.
factory PostDetailsPage.withSampleData() {
return new PostDetailsPage(
_createSampleData(),
// Disable animations for image tests.
animate: false,
);
}
@override
Widget build(BuildContext context) {
return new charts.BarChart(
seriesList,
animate: animate,
);
}
/// Create one series with sample hard coded data.
static List<charts.Series<OrdinalSales, String>> _createSampleData() {
final data = [
new OrdinalSales('2014', 5),
new OrdinalSales('2015', 25),
new OrdinalSales('2016', 100),
new OrdinalSales('2017', 75),
];
return [
new charts.Series<OrdinalSales, String>(
id: 'Sales',
colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault,
domainFn: (OrdinalSales sales, _) => sales.year,
measureFn: (OrdinalSales sales, _) => sales.sales,
data: data,
)
];
}
}
/// Sample ordinal data type.
class OrdinalSales {
final String year;
final int sales;
OrdinalSales(this.year, this.sales);
}
UPDATED 2: FIXED
Main.dart
import 'package:flutter/material.dart';
import 'package:fluttercrud/screens/login_page.dart';
import 'package:fluttercrud/screens/home_page.dart';
import 'package:fluttercrud/screens/partials/list_post.dart';
import 'package:fluttercrud/screens/maps_page.dart';
import 'package:fluttercrud/screens/post_details_page.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
final routes = <String, WidgetBuilder>{
LoginPage.tag: (context) => LoginPage(),
HomePage.tag: (context) => HomePage(),
ListPost.tag: (context) => ListPost(),
MapsPage.tag: (context) => MapsPage(),
PostDetailsPage.tag: (context) => PostDetailsPage(),
};
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'iGota',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch : Colors.blue,
),
home: LoginPage(),
routes: routes,
);
}
}
PostDetailsPage.dart
import 'package:flutter/material.dart';
import 'package:charts_flutter/flutter.dart' as charts;
class PostDetailsPage extends StatefulWidget {
static String tag = 'post-details-page';
@override
PostDetailsPageState createState() => new PostDetailsPageState();
}
class PostDetailsPageState extends State<PostDetailsPage> {
List<charts.Series> seriesList = ;
bool animate;
void initState() {
super.initState();
seriesList = _createSampleData();
animate = false;
}
@override
Widget build(BuildContext context) {
return new Container(
decoration: new BoxDecoration(color: Colors.white),
child: new charts.BarChart(
seriesList,
animate: animate,
),
);
}
/// Create one series with sample hard coded data.
static List<charts.Series<OrdinalSales, String>> _createSampleData() {
final data = [
new OrdinalSales('2014', 5),
new OrdinalSales('2015', 25),
new OrdinalSales('2016', 100),
new OrdinalSales('2017', 75),
];
return [
new charts.Series<OrdinalSales, String>(
id: 'Sales',
colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault,
domainFn: (OrdinalSales sales, _) => sales.year,
measureFn: (OrdinalSales sales, _) => sales.sales,
data: data,
)
];
}
}
/// Sample ordinal data type.
class OrdinalSales {
final String year;
final int sales;
OrdinalSales(this.year, this.sales);
}
dart flutter
I´m trying to navigate between two pages. In second page I need a constructor so i need to declare the variable null in first page and initialize it in the second page.
In main.dart (first page) i have similar to
PostDetailsPage.tag: (context) => PostDetailsPage(new List()),
In the second page (PostDetailsPage) i have this
final List<charts.Series> seriesList;
final bool animate;
PostDetailsPage(this.seriesList, {this.animate});
When i go to page two return
< List < Series< dynamic, dynamic > > is not a subtype of type < List < Series< dynamic, String>>
So how can i solve? Initializate the value in first page and pass it? Initializate value as null in first page and pass it?
UPDATED
Main.dart class
import 'package:flutter/material.dart';
import 'package:fluttercrud/screens/login_page.dart';
import 'package:fluttercrud/screens/home_page.dart';
import 'package:fluttercrud/screens/partials/list_post.dart';
import 'package:fluttercrud/screens/maps_page.dart';
import 'package:fluttercrud/screens/post_details_page.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
final routes = <String, WidgetBuilder>{
LoginPage.tag: (context) => LoginPage(),
HomePage.tag: (context) => HomePage(),
ListPost.tag: (context) => ListPost(),
MapsPage.tag: (context) => MapsPage(),
PostDetailsPage.tag: (context) => PostDetailsPage(new List()),
};
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'iGota',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch : Colors.blue,
),
home: LoginPage(),
routes: routes,
);
}
}
PostDetailsPage.dart class
import 'package:flutter/material.dart';
import 'package:charts_flutter/flutter.dart' as charts;
class PostDetailsPage extends StatelessWidget{
static String tag = 'post-details-page';
final List<charts.Series> seriesList;
final bool animate;
PostDetailsPage(this.seriesList, {this.animate});
/// Creates a [BarChart] with sample data and no transition.
factory PostDetailsPage.withSampleData() {
return new PostDetailsPage(
_createSampleData(),
// Disable animations for image tests.
animate: false,
);
}
@override
Widget build(BuildContext context) {
return new charts.BarChart(
seriesList,
animate: animate,
);
}
/// Create one series with sample hard coded data.
static List<charts.Series<OrdinalSales, String>> _createSampleData() {
final data = [
new OrdinalSales('2014', 5),
new OrdinalSales('2015', 25),
new OrdinalSales('2016', 100),
new OrdinalSales('2017', 75),
];
return [
new charts.Series<OrdinalSales, String>(
id: 'Sales',
colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault,
domainFn: (OrdinalSales sales, _) => sales.year,
measureFn: (OrdinalSales sales, _) => sales.sales,
data: data,
)
];
}
}
/// Sample ordinal data type.
class OrdinalSales {
final String year;
final int sales;
OrdinalSales(this.year, this.sales);
}
UPDATED 2: FIXED
Main.dart
import 'package:flutter/material.dart';
import 'package:fluttercrud/screens/login_page.dart';
import 'package:fluttercrud/screens/home_page.dart';
import 'package:fluttercrud/screens/partials/list_post.dart';
import 'package:fluttercrud/screens/maps_page.dart';
import 'package:fluttercrud/screens/post_details_page.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
final routes = <String, WidgetBuilder>{
LoginPage.tag: (context) => LoginPage(),
HomePage.tag: (context) => HomePage(),
ListPost.tag: (context) => ListPost(),
MapsPage.tag: (context) => MapsPage(),
PostDetailsPage.tag: (context) => PostDetailsPage(),
};
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'iGota',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch : Colors.blue,
),
home: LoginPage(),
routes: routes,
);
}
}
PostDetailsPage.dart
import 'package:flutter/material.dart';
import 'package:charts_flutter/flutter.dart' as charts;
class PostDetailsPage extends StatefulWidget {
static String tag = 'post-details-page';
@override
PostDetailsPageState createState() => new PostDetailsPageState();
}
class PostDetailsPageState extends State<PostDetailsPage> {
List<charts.Series> seriesList = ;
bool animate;
void initState() {
super.initState();
seriesList = _createSampleData();
animate = false;
}
@override
Widget build(BuildContext context) {
return new Container(
decoration: new BoxDecoration(color: Colors.white),
child: new charts.BarChart(
seriesList,
animate: animate,
),
);
}
/// Create one series with sample hard coded data.
static List<charts.Series<OrdinalSales, String>> _createSampleData() {
final data = [
new OrdinalSales('2014', 5),
new OrdinalSales('2015', 25),
new OrdinalSales('2016', 100),
new OrdinalSales('2017', 75),
];
return [
new charts.Series<OrdinalSales, String>(
id: 'Sales',
colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault,
domainFn: (OrdinalSales sales, _) => sales.year,
measureFn: (OrdinalSales sales, _) => sales.sales,
data: data,
)
];
}
}
/// Sample ordinal data type.
class OrdinalSales {
final String year;
final int sales;
OrdinalSales(this.year, this.sales);
}
dart flutter
dart flutter
edited Nov 9 at 20:03
asked Nov 9 at 15:39
El Hombre Sin Nombre
176214
176214
post the real code, what are you passing as an argument forPostDetailsPage
because the problem is just in the types you need to be explicit about them
– Raouf Rahiche
Nov 9 at 15:52
Updated with all code.
– El Hombre Sin Nombre
Nov 9 at 16:21
you are passing an invalid listnew List()
toPostDetailsPage
so you need to provide a real list as an argument
– Raouf Rahiche
Nov 9 at 16:30
Can you put a example?
– El Hombre Sin Nombre
Nov 9 at 16:46
add a comment |
post the real code, what are you passing as an argument forPostDetailsPage
because the problem is just in the types you need to be explicit about them
– Raouf Rahiche
Nov 9 at 15:52
Updated with all code.
– El Hombre Sin Nombre
Nov 9 at 16:21
you are passing an invalid listnew List()
toPostDetailsPage
so you need to provide a real list as an argument
– Raouf Rahiche
Nov 9 at 16:30
Can you put a example?
– El Hombre Sin Nombre
Nov 9 at 16:46
post the real code, what are you passing as an argument for
PostDetailsPage
because the problem is just in the types you need to be explicit about them– Raouf Rahiche
Nov 9 at 15:52
post the real code, what are you passing as an argument for
PostDetailsPage
because the problem is just in the types you need to be explicit about them– Raouf Rahiche
Nov 9 at 15:52
Updated with all code.
– El Hombre Sin Nombre
Nov 9 at 16:21
Updated with all code.
– El Hombre Sin Nombre
Nov 9 at 16:21
you are passing an invalid list
new List()
to PostDetailsPage
so you need to provide a real list as an argument– Raouf Rahiche
Nov 9 at 16:30
you are passing an invalid list
new List()
to PostDetailsPage
so you need to provide a real list as an argument– Raouf Rahiche
Nov 9 at 16:30
Can you put a example?
– El Hombre Sin Nombre
Nov 9 at 16:46
Can you put a example?
– El Hombre Sin Nombre
Nov 9 at 16:46
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
You can fix your issue by explicitly declaring the type on the List
when you pass it in.
PostDetailsPage.tag: (context) => PostDetailsPage(List<charts.Series<dynamic, String>>()),
Or, you can explicitly declare the type of the list itself on the page itself:
final List<charts.Series<dynamic, String>> seriesList;
I think the intended way for the charts library to work is that you pass in an already initialized list of chart data, which the page then renders. If you want to return just with the given sample data, you should just use the given factory method PostDetailsPage.withSampleData()
.
See the updated 2, i fix my problem.
– El Hombre Sin Nombre
Nov 9 at 21:02
@ElHombreSinNombre As you found yourself, you can modify your list with aStatefulWidget
, but unless you intend your graph to be heavily dynamic and need to change the list value frequently, it would probably be better to use aStatelessWidget
– Ringil
Nov 9 at 21:07
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
You can fix your issue by explicitly declaring the type on the List
when you pass it in.
PostDetailsPage.tag: (context) => PostDetailsPage(List<charts.Series<dynamic, String>>()),
Or, you can explicitly declare the type of the list itself on the page itself:
final List<charts.Series<dynamic, String>> seriesList;
I think the intended way for the charts library to work is that you pass in an already initialized list of chart data, which the page then renders. If you want to return just with the given sample data, you should just use the given factory method PostDetailsPage.withSampleData()
.
See the updated 2, i fix my problem.
– El Hombre Sin Nombre
Nov 9 at 21:02
@ElHombreSinNombre As you found yourself, you can modify your list with aStatefulWidget
, but unless you intend your graph to be heavily dynamic and need to change the list value frequently, it would probably be better to use aStatelessWidget
– Ringil
Nov 9 at 21:07
add a comment |
up vote
0
down vote
You can fix your issue by explicitly declaring the type on the List
when you pass it in.
PostDetailsPage.tag: (context) => PostDetailsPage(List<charts.Series<dynamic, String>>()),
Or, you can explicitly declare the type of the list itself on the page itself:
final List<charts.Series<dynamic, String>> seriesList;
I think the intended way for the charts library to work is that you pass in an already initialized list of chart data, which the page then renders. If you want to return just with the given sample data, you should just use the given factory method PostDetailsPage.withSampleData()
.
See the updated 2, i fix my problem.
– El Hombre Sin Nombre
Nov 9 at 21:02
@ElHombreSinNombre As you found yourself, you can modify your list with aStatefulWidget
, but unless you intend your graph to be heavily dynamic and need to change the list value frequently, it would probably be better to use aStatelessWidget
– Ringil
Nov 9 at 21:07
add a comment |
up vote
0
down vote
up vote
0
down vote
You can fix your issue by explicitly declaring the type on the List
when you pass it in.
PostDetailsPage.tag: (context) => PostDetailsPage(List<charts.Series<dynamic, String>>()),
Or, you can explicitly declare the type of the list itself on the page itself:
final List<charts.Series<dynamic, String>> seriesList;
I think the intended way for the charts library to work is that you pass in an already initialized list of chart data, which the page then renders. If you want to return just with the given sample data, you should just use the given factory method PostDetailsPage.withSampleData()
.
You can fix your issue by explicitly declaring the type on the List
when you pass it in.
PostDetailsPage.tag: (context) => PostDetailsPage(List<charts.Series<dynamic, String>>()),
Or, you can explicitly declare the type of the list itself on the page itself:
final List<charts.Series<dynamic, String>> seriesList;
I think the intended way for the charts library to work is that you pass in an already initialized list of chart data, which the page then renders. If you want to return just with the given sample data, you should just use the given factory method PostDetailsPage.withSampleData()
.
answered Nov 9 at 20:53
Ringil
3,40021025
3,40021025
See the updated 2, i fix my problem.
– El Hombre Sin Nombre
Nov 9 at 21:02
@ElHombreSinNombre As you found yourself, you can modify your list with aStatefulWidget
, but unless you intend your graph to be heavily dynamic and need to change the list value frequently, it would probably be better to use aStatelessWidget
– Ringil
Nov 9 at 21:07
add a comment |
See the updated 2, i fix my problem.
– El Hombre Sin Nombre
Nov 9 at 21:02
@ElHombreSinNombre As you found yourself, you can modify your list with aStatefulWidget
, but unless you intend your graph to be heavily dynamic and need to change the list value frequently, it would probably be better to use aStatelessWidget
– Ringil
Nov 9 at 21:07
See the updated 2, i fix my problem.
– El Hombre Sin Nombre
Nov 9 at 21:02
See the updated 2, i fix my problem.
– El Hombre Sin Nombre
Nov 9 at 21:02
@ElHombreSinNombre As you found yourself, you can modify your list with a
StatefulWidget
, but unless you intend your graph to be heavily dynamic and need to change the list value frequently, it would probably be better to use a StatelessWidget
– Ringil
Nov 9 at 21:07
@ElHombreSinNombre As you found yourself, you can modify your list with a
StatefulWidget
, but unless you intend your graph to be heavily dynamic and need to change the list value frequently, it would probably be better to use a StatelessWidget
– Ringil
Nov 9 at 21:07
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53228845%2fcan%25c2%25b4t-pass-null-variable-between-two-pages-in-flutter%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
post the real code, what are you passing as an argument for
PostDetailsPage
because the problem is just in the types you need to be explicit about them– Raouf Rahiche
Nov 9 at 15:52
Updated with all code.
– El Hombre Sin Nombre
Nov 9 at 16:21
you are passing an invalid list
new List()
toPostDetailsPage
so you need to provide a real list as an argument– Raouf Rahiche
Nov 9 at 16:30
Can you put a example?
– El Hombre Sin Nombre
Nov 9 at 16:46