Skip to content

Instantly share code, notes, and snippets.

@micimize
micimize / tab_navigating_scaffold.dart
Last active April 3, 2024 19:52
Approach for tab-local navigators in flutter. Generalized from https://stackoverflow.com/a/57627826/2234013
import 'package:flutter/material.dart';
class AppScaffold extends StatefulWidget {
final List<WidgetBuilder> pages;
final List<BottomNavigationBarItem> navItems;
const AppScaffold({
Key key,
@required this.pages,
@required this.navItems,
@renatoathaydes
renatoathaydes / Dockerfile
Created July 6, 2019 11:28
Minimalistic Docker image from a simple Dart application - includes only the AOT-compiled app and dartaotruntime.
FROM google/dart AS dartc
WORKDIR /app
ADD pubspec.* /app/
RUN pub get
ADD bin/ /app/bin/
ADD lib/ /app/lib/
RUN pub get --offline
RUN dart2aot /app/bin/main.dart /app/main.aot
@PlugFox
PlugFox / dottedBorder.dart
Last active February 15, 2021 07:22
Flutter Web simple file upload
import 'package:flutter_web/material.dart';
import 'dart:math' as math;
class DottedBorder extends StatelessWidget {
final Color color;
final double strokeWidth;
final double gap;
final Widget child;
final EdgeInsets padding;
@timonus
timonus / programmatic-dynamic-images.m
Last active January 1, 2024 12:08
Programmatically create iOS 13 dynamic images
- (UIImage *)dynamicImage
{
UITraitCollection *const baseTraitCollection = /* an existing trait collection */;
UITraitCollection *const lightTraitCollection = [UITraitCollection traitCollectionWithTraitsFromCollections:@[baseTraitCollection, [UITraitCollection traitCollectionWithUserInterfaceStyle:UIUserInterfaceStyleLight]]];
UITraitCollection *const purelyDarkTraitCollection = [UITraitCollection traitCollectionWithUserInterfaceStyle:UIUserInterfaceStyleDark];
UITraitCollection *const darkTraitCollection = [UITraitCollection traitCollectionWithTraitsFromCollections:@[baseTraitCollection, purelyDarkTraitCollection]];
__block UIImage *lightImage;
[lightTraitCollection performAsCurrentTraitCollection:^{
lightImage = /* draw image */;
use std::collections::HashMap;
use std::fmt;
use std::io;
use std::num::ParseFloatError;
use std::rc::Rc;
/*
Types
*/
@tomaszpolanski
tomaszpolanski / guide.txt
Created April 20, 2019 10:40
Building Flutter for MacOS
- `flutter channel master && flutter doctor`
- `export ENABLE_FLUTTER_DESKTOP=true`
- `git clone git@github.com:google/flutter-desktop-embedding.git`
- Move your project inside the `flutter-desktop-embedding` folder
- Copy the `macos` folder from `flutter-desktop-embedding/example` to your project
- `cd flutter-desktop-embedding/my-project && flutter run -d macos`
@slightfoot
slightfoot / run_logged.dart
Created April 11, 2019 11:02
Logging your app's print statements to a local file for later processing.
import 'dart:async';
import 'dart:core';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:path/path.dart' as p;
import 'package:path_provider/path_provider.dart';
void main() => runLoggedApp(App());
@slightfoot
slightfoot / rubber_range_picker.dart
Last active January 19, 2023 01:09
Rubber Range Picker - Based on https://dribbble.com/shots/6101178-Rubber-Range-Picker-Open-Source by Cuberto - 14th March 2019
import 'dart:math' as math;
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/scheduler.dart';
void main() => runApp(ExampleApp());
class ExampleApp extends StatelessWidget {
@override
@trey-rosius
trey-rosius / CustomTabBar.dart
Created March 12, 2019 11:06
Customized Tab Bar for Login,Sign Up and Forgot Password
import 'package:flutter/material.dart';
void main() {
runApp(HomePage());
}
class HomePage extends StatefulWidget {
@override
@sma
sma / example.dart
Last active July 12, 2023 03:00
A flutter example demonstrating a custom painter drawing selectable rects
// run in DartPad: <https://dartpad.dev/c6a9111d58c3deb83711106cec6152ee>
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(home: RectsExample()));
}
class RectsExample extends StatefulWidget {
@override