Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ repo:
flutter: https://github.com/flutter/flutter
samples: https://github.com/flutter/samples
packages: https://github.com/flutter/packages
gallery: https://github.com/flutter/gallery
gallery-archive: https://github.com/flutter/gallery
engine: https://github.com/flutter/engine
uxr: https://github.com/flutter/uxr
wonderous: https://github.com/gskinnerTeam/flutter-wonderous-app
dart:
api: https://api.dart.dev
sdk:
Expand All @@ -39,7 +40,7 @@ pub-pkg: https://pub.dev/packages
flutter-medium: https://medium.com/flutter
medium: https://medium.com
dartpad: https://dartpad.dev
gallery: https://gallery.flutter.dev
gallery-archive: https://flutter-gallery-archive.web.app
material: https://m3.material.io
material2: https://m2.material.io
so: https://stackoverflow.com
Expand All @@ -52,6 +53,7 @@ developers: https://developers.google.com
codelabs: https://codelabs.developers.google.com
groups: https://groups.google.com
firebase: https://firebase.google.com
wonderous: https://wonderous.app/
youtube-site: https://youtube.com

## Software minimum versions
Expand Down
8 changes: 8 additions & 0 deletions examples/layout/gallery/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Examples referenced in
["Layouts in Flutter"](https://docs.flutter.dev/ui/layout) that come from
the now-archived [Flutter Gallery](https://docs.flutter.dev/gallery).
They are mostly the same with a few updates to run standalone,
use new language features, and follow modern Dart/Flutter style.

These should eventually be updated, replaced, removed, or similar
as the layout documentation is rewritten.
5 changes: 5 additions & 0 deletions examples/layout/gallery/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Take our settings from the example_utils analysis_options.yaml file.
# If necessary for a particular example, this file can also include
# overrides for individual lints.

include: package:example_utils/analysis.yaml
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
177 changes: 177 additions & 0 deletions examples/layout/gallery/lib/bottom_navigation_demo.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
// Copyright 2019 The Flutter team. 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:animations/animations.dart';
import 'package:flutter/material.dart';

class BottomNavigationDemo extends StatefulWidget {
const BottomNavigationDemo({
super.key,
required this.restorationId,
required this.type,
});

final String restorationId;
final BottomNavigationDemoType type;

@override
State<BottomNavigationDemo> createState() => _BottomNavigationDemoState();
}

class _BottomNavigationDemoState extends State<BottomNavigationDemo>
with RestorationMixin {
final RestorableInt _currentIndex = RestorableInt(0);

@override
String get restorationId => widget.restorationId;

@override
void restoreState(RestorationBucket? oldBucket, bool initialRestore) {
registerForRestoration(_currentIndex, 'bottom_navigation_tab_index');
}

@override
void dispose() {
_currentIndex.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
final colorScheme = Theme.of(context).colorScheme;
final textTheme = Theme.of(context).textTheme;

var bottomNavigationBarItems = <BottomNavigationBarItem>[
const BottomNavigationBarItem(
icon: Icon(Icons.add_comment),
label: 'Comments',
),
const BottomNavigationBarItem(
icon: Icon(Icons.calendar_today),
label: 'Calendar',
),
const BottomNavigationBarItem(
icon: Icon(Icons.account_circle),
label: 'Account',
),
const BottomNavigationBarItem(
icon: Icon(Icons.alarm_on),
label: 'Alarm',
),
const BottomNavigationBarItem(
icon: Icon(Icons.camera_enhance),
label: 'Camera',
),
];

if (widget.type == BottomNavigationDemoType.withLabels) {
bottomNavigationBarItems = bottomNavigationBarItems.sublist(
0, bottomNavigationBarItems.length - 2);
_currentIndex.value = _currentIndex.value
.clamp(0, bottomNavigationBarItems.length - 1)
.toInt();
}

return MaterialApp(
home: Scaffold(
appBar: AppBar(
automaticallyImplyLeading: false,
title: Text(
switch (widget.type) {
BottomNavigationDemoType.withLabels => 'Persistent labels',
BottomNavigationDemoType.withoutLabels => 'Selected label',
},
),
),
body: Center(
child: PageTransitionSwitcher(
transitionBuilder: (child, animation, secondaryAnimation) {
return FadeThroughTransition(
animation: animation,
secondaryAnimation: secondaryAnimation,
child: child,
);
},
child: _NavigationDestinationView(
// Adding [UniqueKey] to make sure the widget rebuilds when transitioning.
key: UniqueKey(),
item: bottomNavigationBarItems[_currentIndex.value],
),
),
),
bottomNavigationBar: BottomNavigationBar(
showUnselectedLabels:
widget.type == BottomNavigationDemoType.withLabels,
items: bottomNavigationBarItems,
currentIndex: _currentIndex.value,
type: BottomNavigationBarType.fixed,
selectedFontSize: textTheme.bodySmall!.fontSize!,
unselectedFontSize: textTheme.bodySmall!.fontSize!,
onTap: (index) {
setState(() {
_currentIndex.value = index;
});
},
selectedItemColor: colorScheme.onPrimary,
unselectedItemColor: colorScheme.onPrimary.withOpacity(0.38),
backgroundColor: colorScheme.primary,
),
),
);
}
}

class _NavigationDestinationView extends StatelessWidget {
const _NavigationDestinationView({
super.key,
required this.item,
});

final BottomNavigationBarItem item;

@override
Widget build(BuildContext context) {
return Stack(
children: [
ExcludeSemantics(
child: Center(
child: Padding(
padding: const EdgeInsets.all(16),
child: ClipRRect(
borderRadius: BorderRadius.circular(8),
child: Image.asset(
'assets/demos/bottom_navigation_background.png',
),
),
),
),
),
Center(
child: IconTheme(
data: const IconThemeData(
color: Colors.white,
size: 80,
),
child: Semantics(
label: 'Placeholder for ${item.label} tab',
child: item.icon,
),
),
),
],
);
}
}

enum BottomNavigationDemoType {
withLabels,
withoutLabels,
}

void main() {
runApp(const BottomNavigationDemo(
type: BottomNavigationDemoType.withLabels,
restorationId: 'bottom_navigation_labels_demo',
));
}
Loading