Flutter

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

Interacting with SVG in Flutter

一世执手 提交于 2021-02-18 18:59:57
问题 I have an SVG which is composed of multiple paths. I would like to have an onTap listener - probably using a GestureDetector and figure out which path was tapped by the user (by class). I've tried a couple of approaches to this: Using flutter_svg package, which does render it correctly but unfortunately does not handle interactable paths. Using built_path and built_path_annotations which supposedly works but I didn't manage to generate the svg map data (dart code outlining the paths), partly

Interacting with SVG in Flutter

元气小坏坏 提交于 2021-02-18 18:59:37
问题 I have an SVG which is composed of multiple paths. I would like to have an onTap listener - probably using a GestureDetector and figure out which path was tapped by the user (by class). I've tried a couple of approaches to this: Using flutter_svg package, which does render it correctly but unfortunately does not handle interactable paths. Using built_path and built_path_annotations which supposedly works but I didn't manage to generate the svg map data (dart code outlining the paths), partly

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

Flutter error on building files in Android Studio

孤者浪人 提交于 2021-02-18 17:54:05
问题 I have newly installed Flutter on Android Studio. I had a source code of flutter which I want to open using it. I installed the latest flutter plugin and flutter SDK. But when I try to run the app, it shows me the following error: Compiler message: /C:/Flutter%20SDK/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.14.4/lib/src/picture_stream.dart:92:3: Error: The superclass, 'Diagnosticable', has no unnamed constructor that takes no arguments. PictureStream(); ^^^^^^^^^^^^^ /C:

Flutter app crashes on concurrent transactions performed on cloud Firestore

允我心安 提交于 2021-02-18 17:49:36
问题 I am trying to develop an app where multiple users log in and completes a poll concurrently. In this, as soon as user submits the answer the transaction is ran to increment the counter for given answer try { DocumentSnapshot freshsnap = await tx.get(reff); try { await tx.update(reff, <String, dynamic>{ '$i': freshsnap['$i'] + 1, }); } catch (error) { print("Error" + error.code); } } catch (error) { if (error is PlatformException && error.code == 'Error performing transaction') { // await tx

Flutter app crashes on concurrent transactions performed on cloud Firestore

北慕城南 提交于 2021-02-18 17:49:31
问题 I am trying to develop an app where multiple users log in and completes a poll concurrently. In this, as soon as user submits the answer the transaction is ran to increment the counter for given answer try { DocumentSnapshot freshsnap = await tx.get(reff); try { await tx.update(reff, <String, dynamic>{ '$i': freshsnap['$i'] + 1, }); } catch (error) { print("Error" + error.code); } } catch (error) { if (error is PlatformException && error.code == 'Error performing transaction') { // await tx

What is the ideal way to scale font size in App Development?

孤人 提交于 2021-02-18 17:49:12
问题 I know this question might sound a bit odd. I am a newbie in Flutter Development. While making my app responsive I always face an issue while scaling the text. If I keep the font size constant (say 10 or 20) it sometimes looks too small on devices with large resolution or too big on small phones. Then I tried scaling it with respect to screen dimensions (like 4% or screen width etc) but then the question remains to scale it with respect to screen height or width ? Hence I want to know what is