Skip to content

Instantly share code, notes, and snippets.

View ScottS2017's full-sized avatar

Scott ScottS2017

View GitHub Profile
@ScottS2017
ScottS2017 / main.dart
Last active March 8, 2023 19:12
Intro to Flutter Workshop Code for Dartpad.
/// You can run this code in Dartpad at https://www.dartpad.dev/6bddcfd50410c7537770cddbf1b637dc
import 'package:flutter/material.dart';
/// The only think that belongs in main is runapp. Normally, this
/// would be in its own file.
void main() {
runApp(const MyApp());
}
@ScottS2017
ScottS2017 / smooth_rotation.dart
Created June 16, 2020 13:09
Code to smoothly handle rotations in Flutter
// MIT License
//
// Copyright (c) 2020 Scott Stoll
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@ScottS2017
ScottS2017 / vns_example.dart
Created April 30, 2020 19:01
An example of the ValueNotifierSimplified approach to State Management
import 'package:flutter/material.dart';
class VnsObject{
/// First, declare / instantiate any private class members
static final List<Color> _colors = [
Colors.white,
Colors.yellow,
Colors.orange,
Colors.purple,
FixedExtentScrollController fixedExtentScrollController =
new FixedExtentScrollController();
ListWheelScrollView(
controller: fixedExtentScrollController,
physics: FixedExtentScrollPhysics(),
children: monthsOfTheYear.map((month) {
return Card(
child: Row(
children: <Widget>[
Expanded(
@ScottS2017
ScottS2017 / main.dart
Last active February 13, 2020 05:01
Flutter on DartPad
import 'package:flutter/material.dart';
class GutsOfMyPage extends StatelessWidget {
const GutsOfMyPage({
Key key,
@required int counter,
}) : _counter = counter, super(key: key);
final int _counter;
final Widget box_constraints_forces_an_infinite_height_or_width =
Column(
children: <Widget>[
Container(
height: double.infinity,
),
],
);
void main() {
runApp(
Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Flexible(
fit: FlexFit.loose,
child: Container(
color: Colors.blue,
height: 100,
Widget brokenCodeRenderFlexError =
Column(
/// A Column's default is "mainAxisSize: MainAxisSize.max,"
/// This means it will try to take all the height it's allowed to.
children: <Widget>[
Container(
height: 300,
width: double.infinity,
color: Colors.red,
),
Expanded({
Key key,
int flex = 1,
@required Widget child,
}) : super(
key: key,
flex: flex,
fit: FlexFit.tight,
child: child,
);
final Widget render_constrained_box_object_was_given_an_infinite_size_during_layout =
Column(
children: <Widget>[
Row(
children: <Widget>[
Container(
child: SizedBox(
height: double.infinity,
),
),