Fetch data from the Soap Webservice
Fetch data from the Soap Webservice
Fetching data from the Web service is necessary for most apps. Thankfully, Dart and Flutter provide tools, such as the
http
package, for this type of work- Add the Packages as a dependency and make necessary imports respectively
dependencies: flutter: sdk: flutter
cupertino_icons: ^0.1.2 http: xml: html_unescape:
Run flutter packages get
to download the package
2. Add import statements to import necessary packages in your dart file.
import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:http/http.dart' as http; import 'dart:convert'; import 'package:async/async.dart'; import 'package:xml/xml.dart' as xml;3. Make a network requestPut this function in your dart file
Future<int> _isGetdata(String number, String Number) async { String url ="url/method_name?Parameter1="1"&Parameter2="2""; print(url); var req = await get(url); print(req.body); var jsondata = json.decode(xml.parse(req.body).children[2].children[0].toString()); print(jsondata); return jsondata;}In this the return type jsondata is integer type because in future<int> we define integer
Future
is a core Dart class for working with async operations. A Future object represents a potential value or error that will be available at some time in the future
Drop your questions and suggestions in the comments section if you have any...!
Comments
Post a Comment