dart

Only static members can be accessed in initializer. Dart2.0

爷,独闯天下 提交于 2021-02-19 02:19:14
问题 I am using banklist in stateful widget. passing list to pageState using List<Bank> bankLists = this.widget.bankLists; Que 1. Why I am getting error at gradientcolor: gradientBankCard("FFB74093","FFB74093")) that only static members can be accessed in initializer? Que 2. How to pass const Data to gradientBankCard method . for Example I want to pass Color.fromRGBO(220, 132, 58, 1.0) to Arguments that gives error to. I List<Bank> bankLists = [ Bank( id: "1", name: "B1", loanAmount: "₹ 250000",

Flutter :[cloud_firestore/unknown] NoSuchMethodError: invalid member on null: 'includeMetadataChanges' (Flutter Web)

烂漫一生 提交于 2021-02-18 22:20:06
问题 I am trying to fetch data from Friebase-firestore and then convert it to model, I used the same code and approach to another project (web project) ,it works fine , but with this project it doesn't work ,I don't know why. I upgrade flutter version, run Flutter doctor , and nothing wrong with the environment setup. here is the code : class dbService{ static final CollectionReference myCollection = FirebaseFirestore.instance.collection('myCollection'); static Future<myModel> getMyInfo() async{

Adding icon to left of DropDownButton (expanded) in flutter

吃可爱长大的小学妹 提交于 2021-02-18 20:41:05
问题 I want to add icon to left of DropDownButton but can't find a way to do so. What I want to achieve is like this: I have tried following code but it places icon to right where I don't want it and it also overrides arrow icon: `@override Widget build(BuildContext context) { return Scaffold( body: Container( margin: EdgeInsets.only(top: 64.0, left: 16.0, right: 16.0), color: Colors.white, child: DropdownButton( icon: Icon( Icons.person, color: Colors.redAccent, size: 20.09, ), isExpanded: true,

Flutter - Why is child widget's initState() is not called on every rebuild of Parent widget?

社会主义新天地 提交于 2021-02-18 20:00:13
问题 I have a Parent widget, which holds some state, a counter in this case. This state is passed on to a Child widget using its constructor. Now, how I understand it, the Child should get re-built every-time Parent 's state changes, since it's inside the build() function of Parent , and build() gets called every-time the state changes. This concept lead me to believe that the INIT STATE! message would be printed every time the counter changes. But it is not the case! I essentially want a "hook"

Flutter - Why is child widget's initState() is not called on every rebuild of Parent widget?

馋奶兔 提交于 2021-02-18 19:57:50
问题 I have a Parent widget, which holds some state, a counter in this case. This state is passed on to a Child widget using its constructor. Now, how I understand it, the Child should get re-built every-time Parent 's state changes, since it's inside the build() function of Parent , and build() gets called every-time the state changes. This concept lead me to believe that the INIT STATE! message would be printed every time the counter changes. But it is not the case! I essentially want a "hook"

How can a named route have URL parameters in flutter web?

二次信任 提交于 2021-02-18 19:57:32
问题 I'm building a web-app which needs to have a route that gets a post ID and then it will fetch the post using the ID. How can I have URL arguments let's say /post/:id so id is the argument My app looks like that currently: class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( // title: "Paste", initialRoute: "/", theme: ThemeData( primarySwatch: Colors.green, primaryColor: Colors.blue ), routes: { "/": (context) => HomePage(), "/post":

How can a named route have URL parameters in flutter web?

ぐ巨炮叔叔 提交于 2021-02-18 19:57:31
问题 I'm building a web-app which needs to have a route that gets a post ID and then it will fetch the post using the ID. How can I have URL arguments let's say /post/:id so id is the argument My app looks like that currently: class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( // title: "Paste", initialRoute: "/", theme: ThemeData( primarySwatch: Colors.green, primaryColor: Colors.blue ), routes: { "/": (context) => HomePage(), "/post":

How to parse a complex(nested) object to JSON and send it to server using HTTP in flutter?

◇◆丶佛笑我妖孽 提交于 2021-02-18 19:17:48
问题 Hi I have a class that have other classes nested in it. I want to covert an object of this into a JSON string and send it to the server. I have tried many answers both from stack overflow and google searches. Non sufficiently answer my question. Any help is appreciated guys. here are my models class Place { String name; String description; List<PhoneNumber> phoneNumbers; List<String> tags; GPSCoordinante gpsCoordinates; List<Service> services; List<Album> albums; SocialMedia socialMedia; List

How to parse a complex(nested) object to JSON and send it to server using HTTP in flutter?

人盡茶涼 提交于 2021-02-18 19:17:28
问题 Hi I have a class that have other classes nested in it. I want to covert an object of this into a JSON string and send it to the server. I have tried many answers both from stack overflow and google searches. Non sufficiently answer my question. Any help is appreciated guys. here are my models class Place { String name; String description; List<PhoneNumber> phoneNumbers; List<String> tags; GPSCoordinante gpsCoordinates; List<Service> services; List<Album> albums; SocialMedia socialMedia; List

Flutter: Error in assigning value to const color

帅比萌擦擦* 提交于 2021-02-18 17:55:28
问题 const color = Colors.red; // no error const color100 = Colors.red[100]; // error If Colors.red is a compile time constant, why Colors.red[100] isn't. 回答1: Because you can only assign constant values to a const variable. And the return type of an operator T1 operator [](T2 i) isn't/can't be declared as const So you can't do const a = b[c]; Like the return type of a function T1 x(T2 y) isn't/can't be declared as const So you can't do const z = x(y); Because when you use an operator or a