Skip to content

Instantly share code, notes, and snippets.

import 'package:flutter/material.dart';
class Home extends StatefulWidget {
const Home({ super.key });
@override
State<Home> createState() => _HomeState();
}
class _HomeState extends State<Home> {
import 'dart:ui' show lerpDouble;
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
class LinearBorderEdge {
const LinearBorderEdge({
this.alignment = 0, // -1 start, 0 center, 1 end
this.size = 1, // 0 to 1, percentage of width/height
}) : assert(size >= 0);
import 'package:flutter/material.dart';
class Home extends StatefulWidget {
const Home({ super.key });
@override
State<Home> createState() => _HomeState();
}
class _HomeState extends State<Home> with SingleTickerProviderStateMixin {
import 'dart:ui' show lerpDouble;
import 'package:flutter/material.dart';
class Home extends StatefulWidget {
const Home({ super.key });
@override
State<Home> createState() => _HomeState();
}
import 'dart:ui' show lerpDouble;
import 'package:flutter/material.dart';
class Home extends StatefulWidget {
const Home({ super.key });
@override
State<Home> createState() => _HomeState();
}
/*
The overall goal here is to trigger an animated transition when the width of the application's window crosses a "breakpoint" threshold. When the window's widget is less than the breakpoint's value we'll show a bottom NavigationBar in the app's Scaffold. Otherwise we'll show a NavigationRail to the left or right of the app's body, depending on the prevailing text direction (see Directionality). The animated transition from bottom navigation bar to rail happens in two discrete steps. For example if window's width gets small and we're transitioning from showing the navigation rail to showing the bottom navgation bar:
1 - Slide the rail out of view and return its horizontal space to the app's body.
2 - Slide the bar into up into view, compressing the app's height.
These two steps, which happen one after the other, will happen over 2500ms and be driven by a single AnimationController. All of the component transitions will happen in the half of that time, so the controller and its duration are defined like t
/*
The overall goal here is to trigger an animated transition when the width of the application's window crosses a "breakpoint" threshold. When the window's widget is less than the breakpoint's value we'll show a bottom NavigationBar in the app's Scaffold. Otherwise we'll show a NavigationRail to the left or right of the app's body, depending on the prevailing text direction (see Directionality). The animated transition from bottom navigation bar to rail happens in two discrete steps. For example if window's width gets small and we're transitioning from showing the navigation rail to showing the bottom navgation bar:
1 - Slide the rail out of view and return its horizontal space to the app's body.
2 - Slide the bar into up into view, compressing the app's height.
These two steps, which happen one after the other, will happen over 2500ms and be driven by a single AnimationController. All of the component transitions will happen in the half of that time, so the controller and its duration are defined like t
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart' show timeDilation;
const double transitionLength = 1250;
class SizeAnimation extends CurvedAnimation {
SizeAnimation(Animation<double> parent) : super(
parent: parent,
curve: const Interval(
/*
The overall goal here is to trigger an animated transition when the width of the application's window crosses a "breakpoint" threshold. When the window's widget is less than the breakpoint's value we'll show a bottom NavigationBar in the app's Scaffold. Otherwise we'll show a NavigationRail to the left or right of the app's body, depending on the prevailing text direction (see Directionality). The animated transition from bottom navigation bar to rail happens in two discrete steps. For example if window's width gets small and we're transitioning from showing the navigation rail to showing the bottom navgation bar:
1 - Slide the rail out of view and return its horizontal space to the app's body.
2 - Slide the bar into up into view, compressing the app's height.
These two steps, which happen one after the other, will happen over 2500ms and be driven by a single AnimationController. All of the component transitions will happen in the half of that time, so the controller and its duration are defined like t
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart' show timeDilation;
const double transitionLength = 1250;
class RailTransition extends StatefulWidget {
const RailTransition({ super.key, required this.animation, required this.child });