Skip to content

Instantly share code, notes, and snippets.

import 'package:flutter/material.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
class ChatBubble extends StatelessWidget {
const ChatBubble({
super.key,
this.child,
this.text,
required this.isUser,
});
@rodydavis
rodydavis / json_canvas.dart
Created March 22, 2024 19:34
Dart classes for JsonCanvas schema
import 'package:dart_mappable/dart_mappable.dart';
part 'schema.mapper.dart';
@MappableClass()
class JsonCanvas with JsonCanvasMappable {
List<JsonCanvasNode> nodes;
List<JsonCanvasEdge> edges;
JsonCanvas({
@rodydavis
rodydavis / main.dart
Created March 6, 2024 23:49
How to Print Multiple Objects to the Console with print()
void main() {
final number = 1;
final str = 'Hello World';
print((number, str));
print((DateTime.now(), str));
print((DateTime.now(), count: number, description: str));
@rodydavis
rodydavis / main.dart
Created March 6, 2024 21:16
Dart method calling
void main() {
myFunction(1, 2, c: 3, d: 4);
myFunction(1, c: 3, d: 4, 2);
myFunction(c: 3, d: 4, 1, 2);
myFunction(c: 3, 1, 2, d: 4);
myFunction.call(1, 2, c: 3, d: 4);
Function.apply(myFunction, [1, 2], {#c: 3, #d: 4});
}
void myFunction(int a, int b, {int? c, int? d}) {
@rodydavis
rodydavis / main.dart
Last active March 6, 2024 21:07
Dart truthy extension
void main() {
print((null, null.isTruthy));
print(('', ''.isTruthy));
print(('false', 'false'.isTruthy));
print(('true', 'true'.isTruthy));
print((0, 0.isTruthy));
print((1, 1.isTruthy));
print((false, false.isTruthy));
print((true, true.isTruthy));
print(([], [].isTruthy));
@rodydavis
rodydavis / material_navigation_view.dart
Created January 10, 2024 22:00
Navigation view similar to Fluent UI built with Material Design 3
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:signals/signals_flutter.dart';
class NavigationView extends StatefulWidget {
const NavigationView({
super.key,
required this.appBar,
required this.items,
this.footerItems = const [],
import 'package:flutter/material.dart';
import 'package:signals/signals_flutter.dart';
class Editor extends StatefulWidget {
const Editor({super.key});
@override
State<Editor> createState() => _EditorState();
}
@rodydavis
rodydavis / rfw.dart
Created December 18, 2023 20:19
Flutter RFW Helper Widget
import 'package:flutter/material.dart';
import 'package:rfw/formats.dart';
import 'package:rfw/rfw.dart';
class Rfw extends StatefulWidget {
const Rfw({
super.key,
required this.source,
this.data = const {},
});
import 'package:sqlite3/sqlite3.dart';
import 'package:sqlite_async/sqlite_async.dart';
typedef RowParser<T> = T Function(Row row);
extension SqliteDatabaseUtils on SqliteDatabase {
Selectable<T> select<T>(
String sql, {
List<Object?> parameters = const [],
Set<String> tables = const {},
import 'package:flutter/material.dart';
import 'package:signals/signals_flutter.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) => const MaterialApp(