-
Notifications
You must be signed in to change notification settings - Fork 27.1k
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
'package:flutter/src/widgets/image.dart': Failed assertion: line 136 pos 15: 'image != null': is not true. #17900
Comments
Sounds like a timing issue. Can you post the code that causes the issue? |
My code of LoginPage is: // Core
import 'dart:async';
import 'package:flutter/material.dart';
// Plugins
import 'package:firebase_auth/firebase_auth.dart';
import 'package:google_sign_in/google_sign_in.dart';
// Pages
import 'package:digital_frame/pages/home.page.dart';
// Services
import 'package:digital_frame/services/storage.services.dart';
import 'package:digital_frame/services/facebook.services.dart';
import 'package:digital_frame/services/share.services.dart';
class LoginPage extends StatefulWidget {
LoginPage({Key key, this.title}) : super(key: key);
final String title;
@override
_LoginPageState createState() => new _LoginPageState();
}
class _LoginPageState extends State<LoginPage> {
static const String _facebook_appID = 'xxxxxxxxxxx';
static const String _facebook_appSecret = 'xxxxxxxxxxxxxx';
String serverURL = "http://10.0.0.3:8810";
final FirebaseAuth _auth = FirebaseAuth.instance;
final GoogleSignIn googleSignIn = new GoogleSignIn();
final FacebookLogin fb = new FacebookLogin(appID: _facebook_appID, appSecret: _facebook_appSecret);
final Map<String, dynamic> headers = new Map<String, dynamic>();
Future _g_firebaseSignIn() async {
// Show Firebase Google SignIn
GoogleSignInAccount googleSI_acc = await googleSignIn.signIn();
GoogleSignInAuthentication gsiAuth = await googleSI_acc.authentication;
FirebaseUser user = await _auth.signInWithGoogle(idToken: gsiAuth.idToken, accessToken: gsiAuth.accessToken);
return FirebaseAuth.instance.currentUser().then((user) {
return user.getIdToken(refresh: true).then((idToken) {
print(idToken);
List<String> splittedName = googleSI_acc.displayName.split(' ');
Map<String, dynamic> googleData = new Map<String, dynamic>();
googleData['accessToken'] = gsiAuth.accessToken;
googleData['idToken'] = idToken;
googleData['userId'] = googleSI_acc.id;
googleData['displayName'] = googleSI_acc.displayName;
googleData['familyName'] = splittedName[splittedName.length - 1];
googleData['givenName'] = splittedName[0];
googleData['photoUrl'] = googleSI_acc.photoUrl;
googleData['email'] = googleSI_acc.email;
googleData['method'] = 'Google';
return googleData;
});
});
}
_loginByGoogle() {
_g_firebaseSignIn().then((userData) async {
// Get digital-frame server accessToken && refreshToken
ShareSerivces.loginReq(url: serverURL + '/app/newUser', headers: null, body: userData).then((res) {
Map<String, dynamic> resData = res['data'];
var dataToSave = {
'accessToken': resData['accessToken'],
'refreshToken': resData['refreshToken'],
'userID': userData['userId'],
'method': userData['method']
};
// Saves The { refreshToken, accessToken, userID, method } in LocalStorage
_saveUserIntoStorage(dataToSave);
Navigator.push(
context,
new MaterialPageRoute(builder: (context) => new HomePage(title: 'Home')),
);
});
});
}
// Map<String, dynamic> is JSON object in dart
_saveUserIntoStorage(dynamic usrData) {
Map<String, dynamic> loginObject = {
'accessToken': usrData['accessToken'],
'refreshToken': usrData['refreshToken'],
'userID': usrData['userID']
};
StorageH.setJSON(StorageH.loginObject, loginObject);
print('Data saved');
}
_logoutByGoogle() {
StorageH.remove(StorageH.loginObject);
googleSignIn.signOut();
print('User signed out (Google)');
}
_loginByFacebook() async {
fb.sign_in().then((token) async {
return await FirebaseAuth.instance.signInWithFacebook(accessToken: token.accessToken).then((facebookUser) {
return facebookUser.getIdToken(refresh: true).then((idToken) {
print('Facebook user: $facebookUser');
Map<String, dynamic> facebookData = new Map<String, dynamic>();
facebookData['idToken'] = idToken;
facebookData['uid'] = facebookUser.uid;
facebookData['displayName'] = facebookUser.displayName;
facebookData['photoUrl'] = facebookUser.photoUrl;
facebookData['email'] = facebookUser.email;
facebookData['method'] = 'Facebook';
return facebookData;
});
});
}).catchError((dynamic onError) {
print(onError);
});
}
void _logoutByFacebook() {
fb.sign_out();
print('User signed out (Facebook)');
}
@override
Widget build(BuildContext context) {
return new Scaffold(
// backgroundColor: new Color.fromRGBO(2, 71, 23, 1.0),
body: new Center(
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Container(
child: new Image.network('https://cdn6.aptoide.com/imgs/2/b/8/2b843bca0e484cd73192c27b31b99064_icon.png?w=100?raw=true'),
width: 80.0,
margin: new EdgeInsets.only(bottom: 10.0),
alignment: new AlignmentDirectional(50.0, 20.0)
),
new Container(
margin: new EdgeInsets.all(5.0),
child: new RaisedButton.icon(
icon: new Icon(Icons.lock_open),
label: new Text('Sign in With Google'),
textColor: Colors.white,
color: Colors.redAccent,
onPressed: () => _loginByGoogle()
)
),
new Container(
child: new RaisedButton.icon(
icon: new Icon(Icons.tag_faces),
label: new Text('Sign in with Facebook'),
color: Colors.blue[900],
textColor: Colors.white,
onPressed: () => _loginByFacebook()
)
)
]
)
)
);
}
} and my flutter doctor output is:
|
I am also getting similar kind of error while testing the app using flutter test
|
Also, similar issue...
|
@yash365 @cathalgreaney seems you just passed |
Thank you.. the underlying issue was with a conflict between two flutter packages I am using together.. they are: |
Following package version combination working when using MapView and Location packages: |
Should also mention, I'm testing on Android API27 emulator.. I experienced issues when testing on Android API 23 emulator. |
terminal display:
my flutter:
|
@lyquocnam what was the intention of your comment? |
Similar issue here too
|
@genchrist your issue is unrelated. |
@agnoam I think this was an issue with your code or perhaps something |
|
@agnoamI had the same problem, but it was because I had a Listview, I replaced it and placed a Column |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
Hi,
I have a compile error just at the first time that I run my app.
The error is:
But when I refresh it again everything is ok.
anyone know what make the problem ?
The text was updated successfully, but these errors were encountered: