Skip to content

Instantly share code, notes, and snippets.

View tolo's full-sized avatar

Tobias Löfstrand tolo

View GitHub Profile
@tolo
tolo / nested_shells_with_modal_route.dart
Created September 10, 2024 11:13
Demo of using StatefulShellRoute in go_router in two nested levels, with modal full screen routes and deep linking
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
final GlobalKey<NavigatorState> _rootNavigatorKey =
GlobalKey<NavigatorState>(debugLabel: 'root');
final GlobalKey<_PagedRootScreenState> _pagedRootScreenKey =
GlobalKey<_PagedRootScreenState>(debugLabel: 'pagedRootScreenState');
// NOTE: This doesn't currently world, but may come soon:
// final GlobalKey<StatefulNavigationShellState> _rootShellStateKey =
@tolo
tolo / shell_with_modal_route.dart
Last active September 10, 2024 11:17
Demo of using StatefulShellRoute in go_router with modal full screen routes and deep linking
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
final GlobalKey<NavigatorState> _rootNavigatorKey =
GlobalKey<NavigatorState>(debugLabel: 'root');
void main() {
runApp(NestedTabNavigationExampleApp());
}
// 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:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:go_router/go_router.dart';
import 'test_helpers.dart';
@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 17, 2024 10:51
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());
}