Skip to content

Instantly share code, notes, and snippets.

View DevKhalyd's full-sized avatar
🎯
Focusing

Rolando Garcia DevKhalyd

🎯
Focusing
View GitHub Profile
@DevKhalyd
DevKhalyd / raised_button_round_corners.dart
Last active June 10, 2020 00:10
Button with round corners
//Flatbutton also works.
RaisedButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0),
side: BorderSide(color: Colors.red)),
onPressed: () {},
color: Colors.red,
textColor: Colors.white,
child: Text("Buy now".toUpperCase(),
style: TextStyle(fontSize: 14)),
@DevKhalyd
DevKhalyd / .dart
Created June 9, 2020 22:21
Custom Painter
import 'package:flutter/material.dart';
class HeaderSlash extends StatelessWidget {
@override
Widget build(BuildContext context) => CustomPaint(
painter: _HeaderSlashCustom(),//The container shape
child: Container(
height: double.infinity,
width: double.infinity,
),
@DevKhalyd
DevKhalyd / wave_header.dart
Last active June 10, 2020 00:09
Wave Header with Custom Gradient
import 'package:flutter/material.dart';
class WaveHeader extends StatelessWidget {
@override
Widget build(BuildContext context) => CustomPaint(
painter: _WaveHeaderCustom(), //The container shape
child: Container(
height: double.infinity,
width: double.infinity,
),
@DevKhalyd
DevKhalyd / copy_with.dart
Created June 13, 2020 02:30
An example of the copyWith method
//Return the same values and If you want to update any value you can put it
Task copyWith(
{String id,
String initDate,
String endDate,
String task,
bool isComplete}) =>
Task(
id: id ?? this.id,
initDate: initDate ?? this.initDate,
@DevKhalyd
DevKhalyd / circles_custom_painter.dart
Created June 16, 2020 18:49
Circles with Custom Painter
//Use CustomPaint Wiget
Container(
padding: EdgeInsets.all(5),
width: 300,
height: 300,
//This class should be used
child: CustomPaint(
painter: _CustomPaint(porcentage),
),
);
@DevKhalyd
DevKhalyd / cupertino_dialog.dart
Created June 17, 2020 04:41
Cupertino Dialog Flutter
CupertinoAlertDialog(
title: Text(title),
content: Text(description),
actions: [
CupertinoDialogAction(
child: Text('No'),
onPressed: onNegativePressed,
),
CupertinoDialogAction(
child: Text('Yes'),
@DevKhalyd
DevKhalyd / material_dialog.dart
Created June 17, 2020 04:49
Material Dialog Flutter
AlertDialog(
title: Text(title),
content: Text(description),
elevation: 16.0,
actions: [
FlatButton(onPressed: onNegativePressed, child: Text('No')),
FlatButton(onPressed: onAffirmativePressed, child: Text('Yes')),
],
);
@DevKhalyd
DevKhalyd / text_widget_validator.dart
Created June 21, 2020 03:59
Validator Text Form Flutter
class MyHomePage extends StatefulWidget {
@override
MyHomePageState createState() {
return new MyHomePageState();
}
}
class MyHomePageState extends State<MyHomePage> {
final _text = TextEditingController();
bool _validate = false;
//With Map function the Iterable can be changed to another type or another value
var numbersByTwo = [1, -2, 3, 42].map((number) => number * 2);
print('Numbers: $numbersByTwo.');
@DevKhalyd
DevKhalyd / utils.dart
Last active July 19, 2022 16:24
Functions Utils in Dart
import 'package:flutter/material.dart';
//Example: https://stackoverflow.com/questions/26748605/how-to-store-function-as-class-member-variable?rq=
//In dart the functions can be Objects
///
typedef Widget BuilderState(
BuildContext context, void Function(void Function()) setState);
double getScreenWidth(BuildContext context) =>
MediaQuery.of(context).size.width;