Skip to content

Flutter http.dart POST Ordered list #431

@kujaomega

Description

@kujaomega

When making an HTTP POST, the lists are loosing the order. This is the case:

import 'dart:async';
import 'dart:convert';
import 'package:http/http.dart' as http;

class MatchClient {
  final String baseUrl;
  final http.Client httpClient;

  MatchClient({
    http.Client httpClient,
    this.baseUrl = 'http://192.168.1.1:8080/match',
}) : this.httpClient = httpClient ?? http.Client();

  Future<QuarterResult> compute(QuarterMatch quarterMatch) async {
    // At this point, the order is maintained
    final body = jsonEncode(quarterMatch);
    // When I make the post, the list inside the object, loose the order
    final response = await httpClient.post(
        Uri.http(baseUrl, '/match'),
        headers: {
          'Content-Type': 'application/json',
        },
        body: body);
    // In the browser the http request is shooted with a disordered list
    final dynamic results = json.decode(response.body);
  }
}

Issue solved, server issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions