Skip to content

Instantly share code, notes, and snippets.

View tolo's full-sized avatar

Tobias Löfstrand tolo

View GitHub Profile
@tolo
tolo / main.dart
Created February 7, 2023 10:52
A better counter
import 'package:flutter/material.dart';
void main() {
runApp(const ABetterCounterApp());
}
/// Out fabolous and improved version of the standard Counter App!
class ABetterCounterApp extends StatelessWidget {
const ABetterCounterApp({super.key});
@tolo
tolo / main.dart
Last active January 19, 2023 16:20
Dart basics - En liten playground för att testa på grunderna i språket Dart
// ignore_for_file: unused_local_variable
// ignore_for_file: avoid_function_literals_in_foreach_calls
// ignore_for_file: unnecessary_type_check
// ignore_for_file: unnecessary_new
void main() {
variables();
strings();
controlFlow();
operators();
@tolo
tolo / stateful_nested_navigation_hero.dart
Last active April 6, 2023 17:36
Example showing how to use go_router to build stateful nested navigation, in combination with Hero animations. Requires https://github.com/flutter/packages/pull/2650 (or https://github.com/tolo/flutter_packages/tree/nested-persistent-navigation).
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:collection/collection.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
final GlobalKey<NavigatorState> _rootNavigatorKey =
GlobalKey<NavigatorState>(debugLabel: 'root');
@tolo
tolo / cupertino_stateful_nested_navigation.dart
Last active November 21, 2023 22:03
Example showing how to use go_router to build stateful nested navigation, using a CupertinoTabBar. Requires https://github.com/flutter/packages/pull/2650 (or https://github.com/tolo/flutter_packages/tree/nested-persistent-navigation).
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:collection/collection.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
final GlobalKey<NavigatorState> _rootNavigatorKey =
@tolo
tolo / stateful_dynamic_navigation.dart
Last active November 22, 2022 03:17
WIP. Example showing how to use go_router to build stateful dynamic navigation (i.e. varying number of nested route branches) with a BottomNavigationBar. Requires https://github.com/flutter/packages/pull/2650
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
// A quick sample showcasing dynamic number of sections in a stateful navigation
// with a bottom navigation bar. Based on stateful_nested_navigation.dart from
@tolo
tolo / nested_navigation_shell_route.dart
Last active March 23, 2024 07:49
Example showing how to use go_router to build persistent nested navigation (i.e. separate nested navigation trees) with a BottomNavigationBar.
// This temporary implementation is now obsolete, see instead:
// https://pub.dev/documentation/go_router/latest/go_router/StatefulShellRoute-class.html
@tolo
tolo / main.dart
Last active May 18, 2022 21:42
RxNumPad (Flutter)
import 'package:flutter/material.dart';
import 'package:rxdart/rxdart.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(RxNumPadApp());
}
@tolo
tolo / main.dart
Last active June 8, 2021 14:44
Flutter Labinar - Lab 2 (complete)
import 'package:flutter/material.dart';
void main() => runApp(SignUpApp());
class SignUpApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
routes: {
@tolo
tolo / main.dart
Last active June 9, 2021 08:57
Flutter Labinar DemoApp (complete)
import 'package:flutter/material.dart';
import 'dart:async';
import 'dart:convert';
// For DartPad:
import 'dart:html' as http; // Cannot use https://pub.dev/packages/http in DartPad...
// For mobile (and web):
//import 'package:http/http.dart' as http;
@tolo
tolo / main.dart
Last active January 18, 2023 14:39
Flutter Labinar - Lab 1 - Counter (complete)
// ignore_for_file: prefer_const_declarations
// ignore_for_file: prefer_const_constructors
// ignore_for_file: prefer_final_fields
// ignore_for_file: use_key_in_widget_constructors
// ignore_for_file: prefer_const_literals_to_create_immutables
// ignore_for_file: prefer_const_constructors_in_immutables
// ignore_for_file: avoid_print
import 'package:flutter/material.dart';