How to solve the error In CachedNetworkImage?
I want to load an image to cache. So I used CachedNetworkImage for that. When a user logged in through gmail account I get the image url and show the image. But I need to keep it in cache.
Here is my code:
new Center(
child: new Column(
children: <Widget>[
new CircleAvatar(
new CachedNetworkImage(
placeholder: CircularProgressIndicator(),
imageUrl: widget.currentUser?.profilUrl,
),
),
],
),
)
I used CachedNetworkImageProvider also but same error is coming for both. The error is
type'CachedNetworkImage'is not a subtype of type 'ImageProvider<dynamic>'
dart flutter
add a comment |
I want to load an image to cache. So I used CachedNetworkImage for that. When a user logged in through gmail account I get the image url and show the image. But I need to keep it in cache.
Here is my code:
new Center(
child: new Column(
children: <Widget>[
new CircleAvatar(
new CachedNetworkImage(
placeholder: CircularProgressIndicator(),
imageUrl: widget.currentUser?.profilUrl,
),
),
],
),
)
I used CachedNetworkImageProvider also but same error is coming for both. The error is
type'CachedNetworkImage'is not a subtype of type 'ImageProvider<dynamic>'
dart flutter
add a comment |
I want to load an image to cache. So I used CachedNetworkImage for that. When a user logged in through gmail account I get the image url and show the image. But I need to keep it in cache.
Here is my code:
new Center(
child: new Column(
children: <Widget>[
new CircleAvatar(
new CachedNetworkImage(
placeholder: CircularProgressIndicator(),
imageUrl: widget.currentUser?.profilUrl,
),
),
],
),
)
I used CachedNetworkImageProvider also but same error is coming for both. The error is
type'CachedNetworkImage'is not a subtype of type 'ImageProvider<dynamic>'
dart flutter
I want to load an image to cache. So I used CachedNetworkImage for that. When a user logged in through gmail account I get the image url and show the image. But I need to keep it in cache.
Here is my code:
new Center(
child: new Column(
children: <Widget>[
new CircleAvatar(
new CachedNetworkImage(
placeholder: CircularProgressIndicator(),
imageUrl: widget.currentUser?.profilUrl,
),
),
],
),
)
I used CachedNetworkImageProvider also but same error is coming for both. The error is
type'CachedNetworkImage'is not a subtype of type 'ImageProvider<dynamic>'
dart flutter
dart flutter
asked Nov 21 '18 at 7:59
Falak Falak
224
224
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
The widget CircleAvatar receives an ImageProvider.
The cached_network_image package offers you two classes to use:
CachedNetworkImage
a Widget you can use to display a cached network image.
CachedNetworkImageProvider
an ImageProvider providing the cached image.
Therefore you gotta use CachedNetworkImageProvider
(2.), if you want to pass it to the CircleAvatar
.
Here is a complete example, that you can copy & paste for trying out:
import 'package:flutter/material.dart';
import 'package:cached_network_image/cached_network_image.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(),
home: Scaffold(
body: Center(
child: CircleAvatar(
backgroundImage: CachedNetworkImageProvider(
'https://upload.wikimedia.org/wikipedia/commons/thumb/7/71/Bill_Gates_Buys_Skype_%285707954468%29.jpg/2560px-Bill_Gates_Buys_Skype_%285707954468%29.jpg'
),
),
),
)
);
}
}
Yes, I usedCachedNetworkImageProvider
but same kind of error is showing.
– Falak
Nov 21 '18 at 8:18
@Falak I added a complete example, you can copy & paste it and try it out. Is the same kind of error still showing up?
– Niklas
Nov 21 '18 at 8:25
Thank you it's working.
– Falak
Nov 21 '18 at 8:50
add a comment |
Just like @Niklas say.
The widget CircleAvatar receives an ImageProvider.
this is how to use:
new Center(
child: new Column(
children: <Widget>[
new CircleAvatar(
backgroundImage: new CachedNetworkImageProvider(
widget.currentUser?.profilUrl,
)
),
],
),
)
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53407527%2fhow-to-solve-the-error-in-cachednetworkimage%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The widget CircleAvatar receives an ImageProvider.
The cached_network_image package offers you two classes to use:
CachedNetworkImage
a Widget you can use to display a cached network image.
CachedNetworkImageProvider
an ImageProvider providing the cached image.
Therefore you gotta use CachedNetworkImageProvider
(2.), if you want to pass it to the CircleAvatar
.
Here is a complete example, that you can copy & paste for trying out:
import 'package:flutter/material.dart';
import 'package:cached_network_image/cached_network_image.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(),
home: Scaffold(
body: Center(
child: CircleAvatar(
backgroundImage: CachedNetworkImageProvider(
'https://upload.wikimedia.org/wikipedia/commons/thumb/7/71/Bill_Gates_Buys_Skype_%285707954468%29.jpg/2560px-Bill_Gates_Buys_Skype_%285707954468%29.jpg'
),
),
),
)
);
}
}
Yes, I usedCachedNetworkImageProvider
but same kind of error is showing.
– Falak
Nov 21 '18 at 8:18
@Falak I added a complete example, you can copy & paste it and try it out. Is the same kind of error still showing up?
– Niklas
Nov 21 '18 at 8:25
Thank you it's working.
– Falak
Nov 21 '18 at 8:50
add a comment |
The widget CircleAvatar receives an ImageProvider.
The cached_network_image package offers you two classes to use:
CachedNetworkImage
a Widget you can use to display a cached network image.
CachedNetworkImageProvider
an ImageProvider providing the cached image.
Therefore you gotta use CachedNetworkImageProvider
(2.), if you want to pass it to the CircleAvatar
.
Here is a complete example, that you can copy & paste for trying out:
import 'package:flutter/material.dart';
import 'package:cached_network_image/cached_network_image.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(),
home: Scaffold(
body: Center(
child: CircleAvatar(
backgroundImage: CachedNetworkImageProvider(
'https://upload.wikimedia.org/wikipedia/commons/thumb/7/71/Bill_Gates_Buys_Skype_%285707954468%29.jpg/2560px-Bill_Gates_Buys_Skype_%285707954468%29.jpg'
),
),
),
)
);
}
}
Yes, I usedCachedNetworkImageProvider
but same kind of error is showing.
– Falak
Nov 21 '18 at 8:18
@Falak I added a complete example, you can copy & paste it and try it out. Is the same kind of error still showing up?
– Niklas
Nov 21 '18 at 8:25
Thank you it's working.
– Falak
Nov 21 '18 at 8:50
add a comment |
The widget CircleAvatar receives an ImageProvider.
The cached_network_image package offers you two classes to use:
CachedNetworkImage
a Widget you can use to display a cached network image.
CachedNetworkImageProvider
an ImageProvider providing the cached image.
Therefore you gotta use CachedNetworkImageProvider
(2.), if you want to pass it to the CircleAvatar
.
Here is a complete example, that you can copy & paste for trying out:
import 'package:flutter/material.dart';
import 'package:cached_network_image/cached_network_image.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(),
home: Scaffold(
body: Center(
child: CircleAvatar(
backgroundImage: CachedNetworkImageProvider(
'https://upload.wikimedia.org/wikipedia/commons/thumb/7/71/Bill_Gates_Buys_Skype_%285707954468%29.jpg/2560px-Bill_Gates_Buys_Skype_%285707954468%29.jpg'
),
),
),
)
);
}
}
The widget CircleAvatar receives an ImageProvider.
The cached_network_image package offers you two classes to use:
CachedNetworkImage
a Widget you can use to display a cached network image.
CachedNetworkImageProvider
an ImageProvider providing the cached image.
Therefore you gotta use CachedNetworkImageProvider
(2.), if you want to pass it to the CircleAvatar
.
Here is a complete example, that you can copy & paste for trying out:
import 'package:flutter/material.dart';
import 'package:cached_network_image/cached_network_image.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(),
home: Scaffold(
body: Center(
child: CircleAvatar(
backgroundImage: CachedNetworkImageProvider(
'https://upload.wikimedia.org/wikipedia/commons/thumb/7/71/Bill_Gates_Buys_Skype_%285707954468%29.jpg/2560px-Bill_Gates_Buys_Skype_%285707954468%29.jpg'
),
),
),
)
);
}
}
edited Nov 21 '18 at 8:25
answered Nov 21 '18 at 8:13
NiklasNiklas
53428
53428
Yes, I usedCachedNetworkImageProvider
but same kind of error is showing.
– Falak
Nov 21 '18 at 8:18
@Falak I added a complete example, you can copy & paste it and try it out. Is the same kind of error still showing up?
– Niklas
Nov 21 '18 at 8:25
Thank you it's working.
– Falak
Nov 21 '18 at 8:50
add a comment |
Yes, I usedCachedNetworkImageProvider
but same kind of error is showing.
– Falak
Nov 21 '18 at 8:18
@Falak I added a complete example, you can copy & paste it and try it out. Is the same kind of error still showing up?
– Niklas
Nov 21 '18 at 8:25
Thank you it's working.
– Falak
Nov 21 '18 at 8:50
Yes, I used
CachedNetworkImageProvider
but same kind of error is showing.– Falak
Nov 21 '18 at 8:18
Yes, I used
CachedNetworkImageProvider
but same kind of error is showing.– Falak
Nov 21 '18 at 8:18
@Falak I added a complete example, you can copy & paste it and try it out. Is the same kind of error still showing up?
– Niklas
Nov 21 '18 at 8:25
@Falak I added a complete example, you can copy & paste it and try it out. Is the same kind of error still showing up?
– Niklas
Nov 21 '18 at 8:25
Thank you it's working.
– Falak
Nov 21 '18 at 8:50
Thank you it's working.
– Falak
Nov 21 '18 at 8:50
add a comment |
Just like @Niklas say.
The widget CircleAvatar receives an ImageProvider.
this is how to use:
new Center(
child: new Column(
children: <Widget>[
new CircleAvatar(
backgroundImage: new CachedNetworkImageProvider(
widget.currentUser?.profilUrl,
)
),
],
),
)
add a comment |
Just like @Niklas say.
The widget CircleAvatar receives an ImageProvider.
this is how to use:
new Center(
child: new Column(
children: <Widget>[
new CircleAvatar(
backgroundImage: new CachedNetworkImageProvider(
widget.currentUser?.profilUrl,
)
),
],
),
)
add a comment |
Just like @Niklas say.
The widget CircleAvatar receives an ImageProvider.
this is how to use:
new Center(
child: new Column(
children: <Widget>[
new CircleAvatar(
backgroundImage: new CachedNetworkImageProvider(
widget.currentUser?.profilUrl,
)
),
],
),
)
Just like @Niklas say.
The widget CircleAvatar receives an ImageProvider.
this is how to use:
new Center(
child: new Column(
children: <Widget>[
new CircleAvatar(
backgroundImage: new CachedNetworkImageProvider(
widget.currentUser?.profilUrl,
)
),
],
),
)
answered Nov 21 '18 at 9:03
dujianchidujianchi
1967
1967
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53407527%2fhow-to-solve-the-error-in-cachednetworkimage%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown