Image becomes blurry after resize & $Scale = true in Chrome - jssor

I'm having an issue where the main slider image and the text of the navigation on the bottom become blurry after resize. On load it is fine, but as soon as you resize the window everything becomes blurry. This is specific to Chrome, other browsers seam fine
Here is an example http://gallery.furnituremix.com/
Here with $scale = false
http://gallery.furnituremix.com/index2.html

It may look blurry if you scale from smaller to bigger size sometimes.
Please make the original size bigger then. You can replace '100px' with '200px', '50px' with '100px'.
<div u="slides" style="cursor: move;">
<div u="prototype" class=p style="POSITION: absolute; WIDTH: 100px; HEIGHT: 50px; TOP: 0; LEFT: 0;">
<div u="thumbnailtemplate" style="WIDTH: 100px; HEIGHT: 50px; border: none; position: absolute; TOP: 0; LEFT: 0; "></div>
</div>
</div>
Also, I noticed that the original size of the main slider is very small, please make it bigger.
<div id="slider1_container" style="margin: 0, auto; position: relative; top: 0px; left: 0px; width: 600px; height: 350px; overflow: hidden; ">
...
<!-- Slides Container -->
<div u="slides" style="cursor: move; position: absolute; left: 0px; top: 0px; width: 600px; height: 300px; overflow: hidden;">

Related

Remove Flutter HTML widget's default padding

There is a default padding in flutter_html already when trying to parse text.
Below is the difference between using HTML(data: ...) and Text(...) widgets.
Top: HTML Widget, Bottom: Text Widget
How can I remove the horizontal padding?
I think HTML or body is having a default padding and/or margin.
Try adding "body": Style(margin: EdgeInsets.zero, padding: EdgeInsets.zero, in the style parameter.
Html has updated, so I update accepted answer:
"body": Style(
padding: EdgeInsets.zero,
margin: Margins(
bottom: Margin.zero(),
left: Margin.zero(),
top: Margin.zero(),
right: Margin.zero(),
),
),
Add 'body': Style(margin: Margins.zero) inside the style parameter curly brackets.

Fill the Widget by image, of which resolution is different

I have a picture 640 * 400
For example if the mobile phone resolution is 1280 * 960
Widget background = new Positioned.fill(
child: Image.asset('images/back.png'),
right: 0,
left: 0
);
the picture is magnified to 640x400 -> 1280x800.
so there appears blank in the screen.
But in this case, I want to magnify to the 1536x960,
It can fill the screen without blank.
How can I make it?
Just set the fit property of the Image to BoxFit.cover:
Positioned.fill(
child: Image.asset('images/back.png', fit: BoxFit.cover),
right: 0,
left: 0
);

WebView without height inside Scroll not working

On Flutter...I tried to add Webview inside all the available containers that support scroll but it didn't work on Android.
ListView(
shrinkWrap: true,
children: <Widget>[
Text("hiiiiiiiiiiiii "),
Text("hiiiiiiiiiiiii "),
Text("hiiiiiiiiiiiii "),
Expanded(
child: WebView(
key: Key("webview1"),
debuggingEnabled: true,
javascriptMode: JavascriptMode.unrestricted,
initialUrl: "https://flutter.dev/")),
Text("hiiiiiiiiiiiii "),
Text("hiiiiiiiiiiiii "),
Text("hiiiiiiiiiiiii "),
],
)
If you want to put your scrollable WebView between other widget's and WebView will be scrollable, other's widget's are not, then just change your ListView for Column like that:
Column(
children: <Widget>[
Text("hiiiiiiiiiiiii "),
Text("hiiiiiiiiiiiii "),
Container(
height: 300,
child: WebView(
key: Key("webview1"),
debuggingEnabled: true,
javascriptMode: JavascriptMode.unrestricted,
initialUrl: "https://flutter.dev/")
),
Text("hiiiiiiiiiiiii "),
Text("hiiiiiiiiiiiii "),
)
But if u want to have some scrollable widgets on top of WebView, then try
CustomScrollView or SliverList.
Can you tell what exact logic you are trying to make?
additions:
If you want to have scrollable area and some WebView inside, you can have to know height of WebView:
ListView(
physics: ClampingScrollPhysics(),
children: <Widget>[
Text("hiiiiiiiiiiiii "),
Text("hiiiiiiiiiiiii "),
ConstrainedBox(
constraints: BoxConstraints(maxHeight: 10000),
child: WebView(
gestureRecognizers: Set()
..add(
Factory<VerticalDragGestureRecognizer>(
() => VerticalDragGestureRecognizer(),
), // or null
),
key: Key("webview1"),
debuggingEnabled: true,
javascriptMode: JavascriptMode.unrestricted,
initialUrl: "https://flutter.dev/")),
Text("hiiiiiiiiiiiii "),
Text("hiiiiiiiiiiiii "),
],
);
Height of WebView you could get dynamically, inspiration is here:
https://gist.github.com/PonnamKarthik/877a90917a576ecff613d5169680d02c
Thank you dubace for your solution gist.github.com/PonnamKarthik/877a90917a576ecff613d5169680d02c
The issue solved and now we can add Webview inside parent scrollable container.
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Code Sample',
builder: (BuildContext context, Widget navigator) {
return MyStatelessWidget();
},
);
}
}
class MyStatelessWidget extends StatefulWidget {
MyStatelessWidget({Key key}) : super(key: key);
#override
_MyStatelessWidgetState createState() => _MyStatelessWidgetState();
}
class _MyStatelessWidgetState extends State<MyStatelessWidget> {
List<WebViewController> _listController = List();
List<double> _heights =
List<double>.generate(htmlStrings.length, (int index) => 20.0);
#override
Widget build(BuildContext context) {
return Scaffold(
body: ListView.builder(
shrinkWrap: true,
itemCount: htmlStrings.length,
itemBuilder: (context, index) {
return Container(
height: _heights[index] ?? 100.0,
child: WebView(
initialUrl:
'data:text/html;base64,${base64Encode(const Utf8Encoder().convert(htmlStrings[index]))}',
onPageFinished: (some) async {
double height = double.parse(await _listController[index]
.evaluateJavascript(
"document.documentElement.scrollHeight;"));
setState(() {
_heights[index] = height;
});
},
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (controller) async {
_listController.add(controller);
},
),
);
},
),
);
}
}
final List<String> htmlStrings = [
'''<p>Table shows some compounds and the name of their manufacturing process</p>
<table style="border-collapse: collapse; width: 100%; height: 85px;" border="1">
<tbody>
<tr style="height: 17px;">
<td style="width: 50%; text-align: center; height: 17px;">Compounds/Elements</td>
<td style="width: 50%; text-align: center; height: 17px;">Manufacture process</td>
</tr>
<tr style="height: 17px;">
<td style="width: 50%; height: 17px;">Nitric acid</td>
<td style="width: 50%; height: 17px;">Ostwald's process</td>
</tr>
<tr style="height: 17px;">
<td style="width: 50%; height: 17px;">Ammonia</td>
<td style="width: 50%; height: 17px;">Haber's process</td>
</tr>
<tr style="height: 17px;">
<td style="width: 50%; height: 17px;">Sulphuric acid</td>
<td style="width: 50%; height: 17px;">Contact process</td>
</tr>
<tr style="height: 17px;">
<td style="width: 50%; height: 17px;">Sodium</td>
<td style="width: 50%; height: 17px;">Down's process</td>
</tr>
</tbody>
</table>''',
'''<p>\(L=[M{L }^{2 }{T }^{-2 }{A }^{-2 }]\)</p>
<p>\(C=[{M }^{-1 }{L }^{-2 }{T }^{4 }{A }^{2 }]\)</p>
<p>\(R=[M{L }^{2 }{T }^{-3 }{A }^{-2 }]\)</p>
<p>\(\therefore \frac {R}{L}=\frac{[M{L }^{2 }{T }^{-2 }{A }^{-2 }]}{[M{L }^{2 }{T }^{-3 }{A }^{-2 }]}=[T]\)</p>''',
'''<p>Displacement(s)\(=\left(13.8\pm0.2\right)m\)</p>
<p>Time(t)\(=\left(4.0\pm0.3\right)s\)</p>
<p>Velocity(v)\(=\frac{13.8}{4.0}=3.45m{s}^{-1}\)</p>
<p>\(\frac{\delta v}{v}=\pm\left(\frac{\delta s}{s}+\frac{\delta t}{t}\right)=\pm\left(\frac{0.2}{13.8}+\frac{0.3}{4.0}\right)=\pm0.0895\)</p>
<p>\(\delta v =\pm0.0895*3.45=\pm0.3\)(rounding off to one place of decimal)</p>
<p>\(v=\left(3.45\pm0.3\right)m{s}^{-1}\)</p>''',
'''<p>The only real numbers satisfying \(x^2=4\) are 2 and -2. But none of them satisfy the final condition, \(x+2=3\). So, there is no real number such that these conditions are met. Hence this is null set.</p>
<p>Note that, for \(x\) to be a memner of \(\{x:p(x),q(x)\}\), <em><strong>both</strong></em> \(p(x)\) and \(q(x)\) should be true.</p>''',
];
First Method :-
Make a full scrollable Widget contains WebView (with dynamic height) and other containers above and below it. all should scroll inside the parent Widget
be sure flutter package:webview_flutter: any are properly install.
1.create Future fxn
String hight;
double webHight =400; //default some value
Future funcThatMakesAsyncCall() async{
var result =
await controller.evaluateJavascript('document.body.scrollHeight');
//here we call javascript for get browser data
setState(() {
hight = result;
},);}
2.we use SingleChildScrollView
scrollDirection: Axis.vertical,
3.Inside use Column
4.finally we use Conatiner
inside Container we use WebView
here Container Code
Container(
height: webHight+20,
child: WebView(
initialUrl: widget.url,
onPageFinished: (webhight)async{
await funcThatMakesAsyncCall();
setState((){
webHight= double.parse(hight);
});
},
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (WebViewController webViewController) {
controller = webViewController;
},
),
),
second method :-
plugin vesion :> webview_flutter: ^3.0.4
Column(
children: [
Container(
height: Get.height * 0.1,
color: Colors.amber,
),
Expanded(
// height: 200,
child: WebView(
gestureNavigationEnabled: true,
gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>{
Factory<OneSequenceGestureRecognizer>(
() => EagerGestureRecognizer(),
),
},
onWebViewCreated: (WebViewController webViewController) {
bscontroller.webcontroller = webViewController;
},
initialUrl: 'https://flutter.dev',
),
)
],
),
when i stuck another time than in same problem and try my old answer but this not work this time for me so, than i figure out another way
and this second answer to same problem
I had the same issue in the beginning. You can specify which gestures get passed
on to the webView widget with the gestureRecognizers parameter. Bellow code helps to capture the vertical scroll event.
WebView(
initialUrl: someUrl,
gestureRecognizers: Set()
..add(Factory<VerticalDragGestureRecognizer>(
() => VerticalDragGestureRecognizer())),
)
I found this post also very useful for webview
The Power of WebViews in Flutter

Easiest way to make a skeleton screen when data is loading

I am new to flutter and i am trying to make something that looks like in the example included in the snippet.
What is the easiest way to do this with dart and flutter.
basically i want to apply a shine animation to a container when the data from the server is still being downloaded.
Thanks
div {
margin: auto;
width: 500px;
height: 600px; /* change height to see repeat-y behavior */
background-image:
radial-gradient( circle 50px at 50px 50px, lightgray 99%, transparent 0 ),
linear-gradient( 100deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.5) 50%, rgba(255, 255, 255, 0) 80% ),
linear-gradient( lightgray 20px, transparent 0 ),
linear-gradient( lightgray 20px, transparent 0 ),
linear-gradient( lightgray 20px, transparent 0 ),
linear-gradient( lightgray 20px, transparent 0 );
background-repeat: repeat-y;
background-size:
100px 200px, /* circle */
50px 200px, /* highlight */
150px 200px,
350px 200px,
300px 200px,
250px 200px;
background-position:
0 0, /* circle */
0 0, /* highlight */
120px 0,
120px 40px,
120px 80px,
120px 120px;
animation: shine 1s infinite;
}
#keyframes shine {
to {
background-position:
0 0,
100% 0, /* move highlight to right */
120px 0,
120px 40px,
120px 80px,
120px 120px;
}
}
<div></div>
You can combine a Stack and Positioned.fill with a FractionallySizedBox to position such gradient on the top of another widget.
Then you can combine it to an AnimationController, an AnimatedBuilder and an Align or FractionallySizedBox to animate the position of the gradient over time.
You'd have this :
class LoadAnimation extends StatefulWidget {
final Widget child;
LoadAnimation({#required this.child, Key key}) : super(key: key);
#override
_LoadAnimationState createState() => _LoadAnimationState();
}
class _LoadAnimationState extends State<LoadAnimation>
with SingleTickerProviderStateMixin {
AnimationController controller;
#override
void initState() {
controller = AnimationController(
vsync: this,
duration: const Duration(seconds: 1),
)..repeat();
super.initState();
}
#override
Widget build(BuildContext context) {
return Stack(
children: <Widget>[
widget.child,
Positioned.fill(
child: ClipRect(
child: AnimatedBuilder(
animation: controller,
builder: (context, child) {
return FractionallySizedBox(
widthFactor: .2,
alignment: AlignmentGeometryTween(
begin: Alignment(-1.0 - .2 * 3, .0),
end: Alignment(1.0 + .2 * 3, .0),
).chain(CurveTween(curve: Curves.easeOut)).evaluate(controller),
child: child,
);
},
child: const DecoratedBox(
decoration: const BoxDecoration(
gradient: const LinearGradient(
colors: const [
Color.fromARGB(0, 255, 255, 255),
Colors.white,
],
),
),
),
)),
),
],
);
}
}
Which you can then use by wrapping any given widget :
LoadAnimation(
child: Container(
height: 100.0,
width: 200.0,
color: Colors.lime,
),
),
Although Rèmi posted a very nice solution, this package should also be mentioned: https://pub.dev/packages/shimmer

jssor tab slider scale height for different content height

In the Jssor Slider http://www.jssor.com/demos/tab-slider.html, second example, the slide content is fixed as 331px.
But the height of my contents is different, how do I scale the height?
Thanks.
Adjust value of 'height: 331px', and 'height: 300px' in the following code,
If you want to add 20px more, you can change it to '351px' and '320px'.
<div id="slider2_container" style="position: relative; top: 0px; left: 0px; width: 602px; height: 331px; background: #fff; overflow: hidden; ">
<!-- Slides Container -->
<div u="slides" style="cursor: move; position: absolute; left:0px; top: 29px; width: 600px; height: 300px; border: 1px solid gray; background-color: #fff;
overflow: hidden;">