Skip to content

Instantly share code, notes, and snippets.

class VideoControlOverlay extends ViewModelWidget<StackedVideoViewModel> {
@override
Widget build(BuildContext context, StackedVideoViewModel model) {
return Container(
height: model.thumbnailHeight,
width: model.thumbnailWidth,
child: Stack(
children: <Widget>[
AnimatedSwitcher(
duration: Duration(milliseconds: 50),
@jtmuller5
jtmuller5 / video_thumbnail.dart
Created January 12, 2021 17:19
Reusable video thumbnail ViewModelWidget
class VideoThumbnail extends ViewModelWidget<StackedVideoViewModel> {
@override
Widget build(BuildContext context, StackedVideoViewModel model) {
return Builder(
builder: (context) {
// If we want to show the full video, we need to scale it to fit the longest side
if (model.showFull) {
bool wideVideo =
model.videoPlayerController.value.size.width >
class StackedVideoView extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ViewModelBuilder<StackedVideoViewModel>.reactive(
viewModelBuilder: () => StackedVideoViewModel(),
onModelReady: (model) {
model.initialize(
'https://www.learningcontainer.com/wp-content/uploads/2020/05/sample-mp4-file.mp4');
},
builder: (context, model, child) {
class StackedVideoView extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ViewModelBuilder<StackedVideoViewModel>.reactive(
viewModelBuilder: () => StackedVideoViewModel(),
onModelReady: (model) {
model.initialize('https://www.learningcontainer.com/wp-content/uploads/2020/05/sample-mp4-file.mp4');
},
builder: (context, model, child) {
return Container(
class StackedVideoViewModel extends BaseViewModel {
VideoPlayerController videoPlayerController;
void initialize(String videoUrl) {
videoPlayerController = VideoPlayerController.network(videoUrl);
videoPlayerController.initialize().then((value) {
notifyListeners();
});
}
@jtmuller5
jtmuller5 / rich_text_underline
Created November 14, 2020 22:03
RichText Underlining
RichText(
text: TextSpan(children: [
TextSpan(text: "Forgot "),
TextSpan(
text: "Password?",
style: TextStyle(
decoration: TextDecoration.underline,
decorationThickness: 2,
decorationStyle: TextDecorationStyle.wavy))
], style: TextStyle(color: Colors.black)))
@jtmuller5
jtmuller5 / hack_text_underline
Created November 14, 2020 21:42
Hacker's Text Underline
Text(
"Forgot Password?",
style: TextStyle(
shadows: [
Shadow(
color: Colors.red,
offset: Offset(0, -5))
],
color: Colors.transparent,
decoration:
@jtmuller5
jtmuller5 / container_text_underline
Created November 14, 2020 21:22
Text Underline with Container
Container(
padding: EdgeInsets.only(
bottom: 5, // Space between underline and text
),
decoration: BoxDecoration(
border: Border(bottom: BorderSide(
color: Colors.amber,
width: 1.0, // Underline thickness
))
),
@jtmuller5
jtmuller5 / custom_text_underline
Created November 14, 2020 21:12
Text underline custom
Text(
"Forgot Password?",
style: TextStyle(
decoration: TextDecoration.underline,
decorationColor: Colors.blue,
decorationThickness: 4,
decorationStyle: TextDecorationStyle.dashed,
),
)
@jtmuller5
jtmuller5 / text_underline
Created November 14, 2020 20:51
Basic text underline
Text(
"Forgot Password?",
style: TextStyle(
decoration: TextDecoration.underline,
),
)