Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Future<HttpClient> is not a subtype of HttpClient #5

Open
Durgeshsinghn70 opened this issue Sep 27, 2019 · 0 comments
Open

Future<HttpClient> is not a subtype of HttpClient #5

Durgeshsinghn70 opened this issue Sep 27, 2019 · 0 comments

Comments

@Durgeshsinghn70
Copy link

Durgeshsinghn70 commented Sep 27, 2019

import 'dart:io';    
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_app_retrofit/example.dart';

class Homepage extends StatefulWidget {
@override
HomepageState createState() => HomepageState();
}

class _HomepageState extends State<Homepage> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
body: Center(
child: FutureBuilder(
future: this._getPosts(),
builder: (context, snapshot) {
switch (snapshot.connectionState) {
case ConnectionState.none:
return CircularProgressIndicator();
break;
case ConnectionState.waiting:
return CircularProgressIndicator();
break;
case ConnectionState.active:
return CircularProgressIndicator();
break;
case ConnectionState.done:
return CircularProgressIndicator();
break;

default:
return CircularProgressIndicator();
     }
   },),
 ),
);
}

Future _getPosts() async {
final dio= Dio();
(dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate = await (client) async {
SecurityContext securityContext=new SecurityContext();
final ByteData crtData = await rootBundle.load('assets/server.crt');
securityContext.setTrustedCertificatesBytes(crtData.buffer.asUint8List());
final ByteData keyBytes = await rootBundle.load('assets/server.key');
securityContext.usePrivateKeyBytes(keyBytes.buffer.asUint8List());
return HttpClient(context: securityContext);
};
final client = RestClient(dio);
client.login('madhusudhan@****.in', '88888');

}}

In flutter we are getting using Dio. I am getting a error using Dio The problem is here that i need to use SSl certificate So i used Dio But now i am getting the below error. Unhandled exception Future is not a subtype of HttpClient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant