Can't load image in stack in flutter - image

I want to load image in my app
in stack
but image not load
I don't have an error
I've add image in pubspec and pub it .
this is part of my code :
InkWell(
child: Stack(
children: <Widget>[
new Image.asset('assets/Images/b.jpg',fit: BoxFit.cover,),
Center(child: Text("something",textAlign: TextAlign.center,)),
]
),
onTap: () {
ListOfEpisode();
print("am");
},
),
I've try it with network image but still not work.
anyone know that why i can't loaded ?

Change it towercase i:
new Image.asset('assets/images/b.jpg',fit: BoxFit.cover,),
In your pubespec you have it assets/images, in your code it's Images. Fix one of them.

Path in your directory and pubsec is:
assets/images/b.jpg
But in your code its:
assets/Images/b.jpg
change path in code to:
assets/images/b.jpg

Related

Matrix for HDR-ISH

I went to create HDR-ISH filter for flutter application. Anyone help me to find matrix for HDR-ISH image? I need Matrix like below code
Container(
child: Center(
child: ColorFiltered(
colorFilter: ColorFilter.matrix([
0.9,0.5,0.1,0.0,0.0,
0.3,0.8,0.1,0.0,0.0,
0.2,0.3,0.5,0.0,0.0,
0.0,0.0,0.0,1.0,0.0
]),
child: Image.asset("assets/sample.png"))),
),
);

Can't set Network Image with error "Exception caught by image resource service ..."

Similar types of problems already on this site but in my case, it is different.
Please, take a look at my code and the error. I can't understand the error.
Here is a part of my code which is causing the error:
....
....
GridTile(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(feedbackItems[index].name),
Expanded(
child: Image.network(
'${feedbackItems[index].photo}'),
),
],
))
....
....
Here is the error:
Please try this.
Container(
height:100,width:100 // you can give height and width there
child: Image.network(
'${feedbackItems[index].photo}', fit: BoxFit.fill,),
),
BASELINK = 'http://xxxx.com/asset/images/'; //defined baselink
Container(
height:100,width:100 // you can give height and width there
child: Image.network(
BASELINK+'${feedbackItems[index].photo}', fit: BoxFit.fill,),
),
use this.
flutter run -d chrome --web-renderer html

Shell commands in Flutter

I am developing a desktop UI in Flutter and I need to create buttons to execute shell commands.
I already can execute some commands simple such as ls -l and it shows its results nicely in the console.
However I need a way to show the results in the main app and not in the console, I have tried the snackbar but it is not so nice and it does not get the outputs from other commands that gives dynamic outputs.
I would like to watch dynamic outputs such as tail -f and top.
How could I open a new window in the flutter app to show the execution of a command?
For now, I have this:
class LsButton extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Center(
child: RaisedButton(
onPressed: () {
Process.run('ls', ['-l']).then((ProcessResult results) {
Flushbar(
title: "Output",
message: results.stdout,
duration: Duration(seconds: 15),
)..show(context);
});
},
child: Text('Show dir contents!',
style: TextStyle(
fontSize: 10,
),)
),
);
}}
Flutter doesn't yet support multiple windows, so currently if you want to do that you'd have to do it via native code, controlled via platform channels.

Flutter Duration User Input

In my app I need the user to give me a duration, I am thinking about seconds and minutes. So after pressing a button i want something like a Pop-Up Window in which the user then can select a duration by scrolling through a list and picking the minutes and seconds (or something similar to that).
After a long internet search I can't find any template which does something like that and I really don't want to code everything by hand. I would appreciate a link to a template and if not maybe suggestions on what would be the right way to do something like that.
You can use flutter_picker package for this.
Following snippet shows an example that takes hours and minutes input from the user:
void onTap() {
Picker(
adapter: NumberPickerAdapter(data: <NumberPickerColumn>[
const NumberPickerColumn(begin: 0, end: 999, suffix: Text(' hours')),
const NumberPickerColumn(begin: 0, end: 60, suffix: Text(' minutes'), jump: 15),
]),
delimiter: <PickerDelimiter>[
PickerDelimiter(
child: Container(
width: 30.0,
alignment: Alignment.center,
child: Icon(Icons.more_vert),
),
)
],
hideHeader: true,
confirmText: 'OK',
confirmTextStyle: TextStyle(inherit: false, color: Colors.red, fontSize: 22),
title: const Text('Select duration'),
selectedTextStyle: TextStyle(color: Colors.blue),
onConfirm: (Picker picker, List<int> value) {
// You get your duration here
Duration _duration = Duration(hours: picker.getSelectedValues()[0], minutes: picker.getSelectedValues()[1]);
},
).showDialog(context);
}

Change the primary image dimension without touching placeholder image size in Flutter

I have a little question about image and preloading in flutter :
How to change the fit value to cover of an image without touching the size of the placeholder ?
Widget primaryVideoImg(img) {
return Flex(
direction: Axis.horizontal,
children: <Widget>[
Expanded(
child: GestureDetector(
child: FadeInImage.assetNetwork(
placeholder: 'res/preloader.gif',
image: 'remote image url',
fit: BoxFit.fill,
)))
],
);
}
As you see in the picture bellow the placeholder take also the whole page.
You can use Stack and some transparent image for placeholder in FadeInImage.assetNetwork to achieve what you want.
For your code it will look something like this:
import 'package:transparent_image/transparent_image.dart';
...
Stack(children: <Widget>[
new Image.asset('res/preloader.gif', fit: BoxFit.fill),
FadeInImage.assetNetwork(
placeholder: kTransparentImage,
image: 'remote image url',
fit: BoxFit.cover,
),
],
);
You can make your own transparent image and attach it to the project.
Or use kTransparentImage presented in transparent_image 0.1.0 plugin:
https://pub.dartlang.org/packages/transparent_image
I find this trick in Flutter cookbook.
For more information look on this link:
https://flutter.io/docs/cookbook/images/fading-in-images
Good Luck!

Resources