Show default message when null or empty

This commit is contained in:
Thomas Fransolet 2021-08-24 20:21:19 +02:00
parent da8b3d88de
commit ba70827448
3 changed files with 32 additions and 25 deletions

View File

@ -145,12 +145,14 @@ class _SliderViewWidget extends State<SliderViewWidget> {
),
],
),
Positioned(
if(sliderDTO.images != null && sliderDTO.images.length > 1)
Positioned(
top: MediaQuery.of(context).size.height * 0.35,
right: 60,
child: InkWell(
onTap: () {
sliderController.nextPage(duration: new Duration(milliseconds: 500), curve: Curves.fastOutSlowIn);
if (sliderDTO.images.length > 0)
sliderController.nextPage(duration: new Duration(milliseconds: 500), curve: Curves.fastOutSlowIn);
},
child: Icon(
Icons.chevron_right,
@ -159,12 +161,14 @@ class _SliderViewWidget extends State<SliderViewWidget> {
),
)
),
Positioned(
if(sliderDTO.images != null && sliderDTO.images.length > 1)
Positioned(
top: MediaQuery.of(context).size.height * 0.35,
left: 60,
child: InkWell(
onTap: () {
sliderController.previousPage(duration: new Duration(milliseconds: 500), curve: Curves.fastOutSlowIn);
if (sliderDTO.images.length > 0)
sliderController.previousPage(duration: new Duration(milliseconds: 500), curve: Curves.fastOutSlowIn);
},
child: Icon(
Icons.chevron_left,
@ -189,6 +193,8 @@ class _SliderViewWidget extends State<SliderViewWidget> {
)
),
),
if(sliderDTO.images == null || sliderDTO.images.length == 0)
Center(child: Text("Aucune image à afficher"))
// Description
/*Container(
height: sliderDTO.images != null && sliderDTO.images.length > 0 ? size.height *0.3 : size.height *0.6,

View File

@ -23,31 +23,32 @@ class _VideoViewWidget extends State<VideoViewWidget> {
print(videoDTO);
String videoId;
videoId = YoutubePlayer.convertUrlToId(videoDTO.source_);
print(videoId);
if (videoDTO.source_ != null && videoDTO.source_.length > 0 ) {
videoId = YoutubePlayer.convertUrlToId(videoDTO.source_);
super.initState();
YoutubePlayerController _controller = YoutubePlayerController(
initialVideoId: videoId,
flags: YoutubePlayerFlags(
autoPlay: true,
controlsVisibleAtStart: false,
loop: true,
hideControls: false,
hideThumbnail: false,
),
);
YoutubePlayerController _controller = YoutubePlayerController(
initialVideoId: videoId,
flags: YoutubePlayerFlags(
autoPlay: true,
controlsVisibleAtStart: false,
loop: true,
hideControls: false,
hideThumbnail: false,
),
);
_videoView = YoutubePlayer(
controller: _controller,
showVideoProgressIndicator: false,
/*progressIndicatorColor: Colors.amber,
_videoView = YoutubePlayer(
controller: _controller,
showVideoProgressIndicator: false,
/*progressIndicatorColor: Colors.amber,
progressColors: ProgressBarColors(
playedColor: Colors.amber,
handleColor: Colors.amberAccent,
),*/
);
);
}
super.initState();
}
@override
@ -57,5 +58,5 @@ class _VideoViewWidget extends State<VideoViewWidget> {
}
@override
Widget build(BuildContext context) => _videoView;
Widget build(BuildContext context) => videoDTO.source_ != null && videoDTO.source_.length > 0 ? _videoView : Center(child: Text("La vidéo ne peut pas être affichée, l'url est incorrecte"));
}

View File

@ -45,5 +45,5 @@ class _WebViewWidget extends State<WebViewWidget> {
}
@override
Widget build(BuildContext context) => _webView;
Widget build(BuildContext context) => webDTO.source_ != null && webDTO.source_.length > 0 ? _webView : Center(child: Text("La page internet ne peut pas être affichée, l'url est incorrecte ou vide"));
}