A url is being shown in WebView and the url contains video and can resize by passing dimension.
Url itself has resized video but WebView not fitting the Url.
“https://storageweweb.blob.core.windows.net/files/INVENTORYDATA/V360Mini5/Vision360.html?d=1616180&autoPlay=1&h=140.0&w=140.0”
Widget _buildVideoWebView(
int index,
String lotId,
) {
return SizedBox(
height: 140,
width: 140,
child: DnaWebViewInterface(
key: webVideoKey[index],
url: getDiamondVideoFileUrl(
lotId,
height: 100,
width: 100,
),
),
);
}
WebView class
class DnaWebViewInterface extends StatefulWidget {
final String url;
final bool allowInteraction;
final void Function(double)? onScaleChanged;
const DnaWebViewInterface({
super.key,
required this.url,
this.allowInteraction = true,
this.onScaleChanged,
});
@override
State<DnaWebViewInterface> createState() => DnaWebViewInterfaceState();
}
class DnaWebViewInterfaceState extends State<DnaWebViewInterface> {
final ValueNotifier<double> _progressValueNotifier =
ValueNotifier<double>(0);
// Ranges from 0 to 1.
late final WebViewController _webViewController = WebViewController()
..setJavaScriptMode(JavaScriptMode.unrestricted)
..loadRequest(Uri.parse(widget.url))
..setNavigationDelegate(
NavigationDelegate(
onProgress: (int progress) {
_progressValueNotifier.value = progress / 100;
},
onPageFinished: (_) {
_progressValueNotifier.value = 1;
},
),
)
..setBackgroundColor(CoreColor.neutral100);
@override
Widget build(BuildContext context) {
return Stack(
children: [
Positioned.fill(
child: WebViewWidget(controller: _webViewController,gestureRecognizers: {
Factory<OneSequenceGestureRecognizer>(
() => EagerGestureRecognizer(),
),
},),
),
Positioned.fill(
child: ValueListenableBuilder(
valueListenable: _progressValueNotifier,
builder: (context, value, _) {
if (value < 1) {
return Center(
child: SizedBox(
height: 48,
width: 48,
child: CircularProgressIndicator(
value: value,
),
),
);
} else {
return const SizedBox();
}
},
),
),
],
);
}
void reloadWebView() {
_webViewController?.reload();
}
}
Want to fit the video in the below design and using this pub dev webview_flutter