skip to Main Content

flutter http POST to google cloud function always returns 415

I try to call a google cloud function from flutter using POST, but it always returns 415. This is the call: http .post( Uri.parse('https://example.com/function'), headers: <String, String>{ 'content-type': 'application/json' }, body: jsonEncode(<String, String>{ "message": "test", "version": "1", }), encoding: Encoding.getByName('utf-8'),…

VIEW QUESTION

Asset not Found in Flutter and Dart

I am getting the "asset not found" error when I try to run my app. Here are my files. main.dart: import 'package:flutter/material.dart'; void main() { runApp(MaterialApp( home: Scaffold( appBar: AppBar( title: Text('I Am Rich'), centerTitle: true, backgroundColor: Colors.blueGrey[900], ), //…

VIEW QUESTION

Change background color of dropdownbutton- flutter

I want to change the background color and border radius of DropDownButton, i have tried it with theme but it changes the color of dropdown not the button Theme( data: Theme.of(context) .copyWith(canvasColor: Colors.blue), child: DropdownButton( items: [DropdownMenuItem(child: Text('one'))], onChanged: (newvlaue)…

VIEW QUESTION

Flutter – ToggleButton not changing state

I have three toggle button in my page. When I click either one of the toggle button, it remain unchanged. class EditInvoiceDetailsScreen extends HookWidget { final Invoice invoice; EditInvoiceDetailsScreen(this.invoice, {super.key}); @override Widget build(BuildContext context) { final isSelected = useState(<bool>[true, false,…

VIEW QUESTION

flutter make get request before displaying app

I have a pretty simple problem. I have a code snippet that looks like this: class home_page extends StatefulWidget { @override State<StatefulWidget> createState() => Main(); } class Main extends State<home_page> { void initState() { super.initState(); } @override Widget build(BuildContext context)…

VIEW QUESTION

How to sort model data received from JSON using flutter_bloc?

I have a model: import 'dart:convert'; Forecast forecastFromJson(String str) => Forecast.fromJson(json.decode(str)); String forecastToJson(Forecast data) => json.encode(data.toJson()); class Forecast { List<ListElement> list; Forecast({ required this.list, }); factory Forecast.fromJson(Map<String, dynamic> json) => Forecast( list: List<ListElement>.from(json["list"].map((x) => ListElement.fromJson(x))), ); Map<String, dynamic> toJson() =>…

VIEW QUESTION
Back To Top
Search