Skip to content

Instantly share code, notes, and snippets.

View artembark's full-sized avatar
🎯
Focusing

Artem Barkalov artembark

🎯
Focusing
View GitHub Profile
@artembark
artembark / squircle_border.dart
Created February 1, 2025 11:56
Squircle border
import 'package:flutter/material.dart';
class SquircleBorder extends ShapeBorder {
final BorderSide side;
final double superRadius;
const SquircleBorder({this.side = BorderSide.none, this.superRadius = 0.0});
@override
EdgeInsetsGeometry get dimensions => EdgeInsets.all(side.width);
@artembark
artembark / main.dart
Last active December 8, 2024 23:55
Pattern matching and destruction playground
/// https://dart.dev/language/patterns
/// https://dart.dev/language/pattern-types
/// https://dart.dev/language/branches#if-case
void main() {
final user = User(name: 'John', secondName: 'Doe', age: 20);
final User(:name, :age) = user;
print('Name: $name');
print('Age: $age');
@artembark
artembark / loval_history_entry.dart
Created October 13, 2024 11:47
Local History Entry
/// from https://api.flutter.dev/flutter/widgets/LocalHistoryRoute/addLocalHistoryEntry.html
import 'package:flutter/material.dart';
void main(){
runApp(App());
}
class App extends StatelessWidget {
const App({super.key});
@artembark
artembark / inherited_get_vs_depend.dart
Last active August 30, 2024 11:21
Inherited widget in initState
/*
* Inherited get vs depend
* https://https://gist.github.com/artembark/a72324442d5c8b0a315a02122343345a/
* https://dartpad.dev?id=a72324442d5c8b0a315a02122343345a
*/
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
@artembark
artembark / custom_clipper_with_path.dart
Created March 29, 2024 13:30
Custom clipper with path
import 'package:flutter/material.dart';
class MyCustomClipper extends CustomClipper<Path> {
@override
Path getClip(Size size) {
Path path_0 = Path();
path_0.moveTo(20,278);
path_0.lineTo(20,32);
path_0.cubicTo(20,25.3726,25.3726,20,32,20);
path_0.lineTo(128.727,20);
@artembark
artembark / main.dart
Last active October 30, 2025 05:44
Custom input border v2
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
@artembark
artembark / main.dart
Last active September 26, 2023 14:47
no padding error
import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
void main() async {
print('Future API no return case:');
try {
final result = await functionThatThrows().catchError((e) {
print('Future API catchError fired with: $e');
});
if (result == true) {
print('Flow continues with true result');
} else {
print('Flow continues with else result');
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.