Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Hoàng Văn Đạt
mypoint_flutter_app
Commits
6fcbfba8
Commit
6fcbfba8
authored
Apr 25, 2025
by
DatHV
Browse files
update voucher tab
parent
d86c3328
Changes
41
Hide whitespace changes
Inline
Side-by-side
lib/widgets/image_loader.dart
0 → 100644
View file @
6fcbfba8
import
'package:flutter/material.dart'
;
Widget
loadNetworkImage
(
{
required
String
?
url
,
BoxFit
fit
=
BoxFit
.
cover
,
double
?
width
,
double
?
height
,
String
placeholderAsset
=
'assets/images/sample.png'
,
})
{
if
(
url
==
null
||
url
.
isEmpty
)
{
return
Image
.
asset
(
placeholderAsset
,
fit:
fit
,
width:
width
,
height:
height
,
);
}
return
Image
.
network
(
url
,
fit:
fit
,
width:
width
,
height:
height
,
loadingBuilder:
(
context
,
child
,
loadingProgress
)
{
if
(
loadingProgress
==
null
)
return
child
;
return
Center
(
child:
SizedBox
(
width:
24
,
height:
24
,
child:
CircularProgressIndicator
(
strokeWidth:
2
,
value:
loadingProgress
.
expectedTotalBytes
!=
null
?
loadingProgress
.
cumulativeBytesLoaded
/
loadingProgress
.
expectedTotalBytes
!
:
null
,
),
),
);
},
errorBuilder:
(
context
,
error
,
stackTrace
)
{
return
Image
.
asset
(
placeholderAsset
,
fit:
fit
,
width:
width
,
height:
height
,
);
},
);
}
Prev
1
2
3
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment