Skip to content

Instantly share code, notes, and snippets.

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,
),
)
@jtmuller5
jtmuller5 / uploadNetworkImage
Created November 5, 2020 19:29
Upload byte data to Cloud Storage
Future<String> uploadNetworkImage(String _image) async {
// Retrieve the image form the tinyPNG URL
http.Response response =
await http.get(_image, headers: {"Content-Type": 'application/json'});
print(response.body);
// Convert to form that can be saved to Cloud Storage
Uint8List networkBytes = response.bodyBytes;
StorageReference storageReference = FirebaseStorage.instance
.ref()
@jtmuller5
jtmuller5 / TinyResponse
Created November 5, 2020 19:26
Tiny Response Class
class TinyResponse {
String url;
void printURL() {
print(url);
}
TinyResponse.fromJson(Map<String, dynamic> json)
: url = json['output']['url'];
}
@jtmuller5
jtmuller5 / tinyFile
Created November 5, 2020 19:25
Make API request to TinyPNG
Future<String> tinyFile(File file) async {
var url = 'https://api.tinify.com/shrink';
TinyResponse tinyResponse;
try {
var response = await http.post(
url,
body: file.readAsBytesSync(),
headers: {
'Authorization':
"Basic {YOUR base64 API KEY}"