-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[flutter_adaptive_scaffold] : 🐛 [FIX] : Issue: 121135. #3253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 11 commits
8397d92
a066163
9817fca
e2d6ee3
43adf69
de2c14a
bb90b3c
20881f0
d2f28f2
bbb65ac
0427ef3
7f4cd28
257cac2
2bb7c6a
41c12e1
90eed41
e0327ae
800cfb1
f7c6f8a
2b6fe71
546aa34
5eb9525
2b42938
fdb67da
5148a75
bbbb7ae
82f05d6
40efe64
b4242bd
bfda115
4ba9ac5
2087935
1215553
d2eb4f8
6a4969f
2f4825b
ef76b42
743e0fb
2df840e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,10 +27,17 @@ class MyApp extends StatelessWidget { | |
|
|
||
| /// Creates a basic adaptive page with navigational elements and a body using | ||
| /// [AdaptiveLayout]. | ||
| class MyHomePage extends StatelessWidget { | ||
| class MyHomePage extends StatefulWidget { | ||
| /// Creates a const [MyHomePage]. | ||
| const MyHomePage({super.key}); | ||
|
|
||
| @override | ||
| State<MyHomePage> createState() => _MyHomePageState(); | ||
| } | ||
|
|
||
| class _MyHomePageState extends State<MyHomePage> { | ||
| int selectedNavigation = 0; | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| // Define the children to display within the body. | ||
|
|
@@ -113,19 +120,23 @@ class MyHomePage extends StatelessWidget { | |
| const List<NavigationDestination> destinations = <NavigationDestination>[ | ||
| NavigationDestination( | ||
| label: 'Inbox', | ||
| icon: Icon(Icons.inbox, color: Colors.black), | ||
| icon: Icon(Icons.inbox_outlined), | ||
gspencergoog marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| selectedIcon: Icon(Icons.inbox), | ||
| ), | ||
| NavigationDestination( | ||
| label: 'Articles', | ||
| icon: Icon(Icons.article_outlined, color: Colors.black), | ||
| icon: Icon(Icons.article_outlined), | ||
| selectedIcon: Icon(Icons.article), | ||
| ), | ||
| NavigationDestination( | ||
| label: 'Chat', | ||
| icon: Icon(Icons.chat_bubble_outline, color: Colors.black), | ||
| icon: Icon(Icons.chat_outlined), | ||
| selectedIcon: Icon(Icons.chat), | ||
| ), | ||
| NavigationDestination( | ||
| label: 'Video', | ||
| icon: Icon(Icons.video_call_outlined, color: Colors.black), | ||
| icon: Icon(Icons.video_call_outlined), | ||
| selectedIcon: Icon(Icons.video_call), | ||
| ), | ||
| ]; | ||
|
|
||
|
|
@@ -142,6 +153,10 @@ class MyHomePage extends StatelessWidget { | |
| inAnimation: AdaptiveScaffold.leftOutIn, | ||
| key: const Key('Primary Navigation Medium'), | ||
| builder: (_) => AdaptiveScaffold.standardNavigationRail( | ||
| selectedIndex: selectedNavigation, | ||
| onDestinationSelected: (int newIndex) { | ||
| setState(() => selectedNavigation = newIndex); | ||
|
||
| }, | ||
| leading: const Icon(Icons.menu), | ||
| destinations: destinations | ||
| .map((_) => AdaptiveScaffold.toRailDestination(_)) | ||
|
|
@@ -152,6 +167,10 @@ class MyHomePage extends StatelessWidget { | |
| key: const Key('Primary Navigation Large'), | ||
| inAnimation: AdaptiveScaffold.leftOutIn, | ||
| builder: (_) => AdaptiveScaffold.standardNavigationRail( | ||
| selectedIndex: selectedNavigation, | ||
| onDestinationSelected: (int newIndex) { | ||
| setState(() => selectedNavigation = newIndex); | ||
| }, | ||
| extended: true, | ||
| leading: Row( | ||
| mainAxisAlignment: MainAxisAlignment.spaceAround, | ||
|
|
@@ -197,11 +216,12 @@ class MyHomePage extends StatelessWidget { | |
| key: const Key('Bottom Navigation Small'), | ||
| inAnimation: AdaptiveScaffold.bottomToTop, | ||
| outAnimation: AdaptiveScaffold.topToBottom, | ||
| builder: (_) => BottomNavigationBarTheme( | ||
| data: const BottomNavigationBarThemeData( | ||
| selectedItemColor: Colors.black), | ||
| child: AdaptiveScaffold.standardBottomNavigationBar( | ||
| destinations: destinations), | ||
| builder: (_) => AdaptiveScaffold.standardBottomNavigationBar( | ||
| destinations: destinations, | ||
| currentIndex: selectedNavigation, | ||
| onDestinationSelected: (int newIndex) { | ||
| setState(() => selectedNavigation = newIndex); | ||
| }, | ||
| ), | ||
| ) | ||
| }, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,10 +22,17 @@ class MyApp extends StatelessWidget { | |
|
|
||
| /// Creates a basic adaptive page with navigational elements and a body using | ||
| /// [AdaptiveScaffold]. | ||
| class MyHomePage extends StatelessWidget { | ||
| class MyHomePage extends StatefulWidget { | ||
| /// Creates a const [MyHomePage]. | ||
| const MyHomePage({super.key}); | ||
|
|
||
| @override | ||
| State<MyHomePage> createState() => _MyHomePageState(); | ||
| } | ||
|
|
||
| class _MyHomePageState extends State<MyHomePage> { | ||
| int _selectedTab = 0; | ||
|
|
||
| // #docregion Example | ||
| @override | ||
| Widget build(BuildContext context) { | ||
|
|
@@ -35,46 +42,64 @@ class MyHomePage extends StatelessWidget { | |
| Padding( | ||
| padding: const EdgeInsets.all(8.0), | ||
| child: Container( | ||
| color: const Color.fromARGB(255, 255, 201, 197), | ||
| color: const Color.fromARGB(255, 255, 29, 197), | ||
|
||
| height: 400, | ||
| ), | ||
| ) | ||
| ]; | ||
|
|
||
| return BottomNavigationBarTheme( | ||
| data: const BottomNavigationBarThemeData( | ||
| unselectedItemColor: Colors.black, | ||
| selectedItemColor: Colors.black, | ||
| backgroundColor: Colors.white, | ||
| return AdaptiveScaffold( | ||
| // An option to override the default breakpoints used for small, medium, | ||
| // and large. | ||
| smallBreakpoint: const WidthPlatformBreakpoint(end: 700), | ||
| mediumBreakpoint: const WidthPlatformBreakpoint(begin: 700, end: 1000), | ||
| largeBreakpoint: const WidthPlatformBreakpoint(begin: 1000), | ||
| useDrawer: false, | ||
| selectedIndex: _selectedTab, | ||
| onSelectedIndexChange: (int index) { | ||
| setState(() => _selectedTab = index); | ||
| }, | ||
| destinations: const <NavigationDestination>[ | ||
| NavigationDestination( | ||
| icon: Icon(Icons.inbox_outlined), | ||
| selectedIcon: Icon(Icons.inbox), | ||
| label: 'Inbox', | ||
| ), | ||
| NavigationDestination( | ||
| icon: Icon(Icons.article_outlined), | ||
| selectedIcon: Icon(Icons.article), | ||
| label: 'Articles', | ||
| ), | ||
| NavigationDestination( | ||
| icon: Icon(Icons.chat_outlined), | ||
| selectedIcon: Icon(Icons.chat), | ||
| label: 'Chat', | ||
| ), | ||
| NavigationDestination( | ||
| icon: Icon(Icons.video_call_outlined), | ||
| selectedIcon: Icon(Icons.video_call), | ||
| label: 'Video', | ||
| ), | ||
| NavigationDestination( | ||
| icon: Icon(Icons.home_outlined), | ||
| selectedIcon: Icon(Icons.home), | ||
| label: 'Inbox', | ||
| ), | ||
| child: AdaptiveScaffold( | ||
| // An option to override the default breakpoints used for small, medium, | ||
| // and large. | ||
| smallBreakpoint: const WidthPlatformBreakpoint(end: 700), | ||
| mediumBreakpoint: | ||
| const WidthPlatformBreakpoint(begin: 700, end: 1000), | ||
| largeBreakpoint: const WidthPlatformBreakpoint(begin: 1000), | ||
| useDrawer: false, | ||
| destinations: const <NavigationDestination>[ | ||
| NavigationDestination(icon: Icon(Icons.inbox), label: 'Inbox'), | ||
| NavigationDestination( | ||
| icon: Icon(Icons.article), label: 'Articles'), | ||
| NavigationDestination(icon: Icon(Icons.chat), label: 'Chat'), | ||
| NavigationDestination( | ||
| icon: Icon(Icons.video_call), label: 'Video') | ||
| ], | ||
| body: (_) => GridView.count(crossAxisCount: 2, children: children), | ||
| smallBody: (_) => ListView.builder( | ||
| itemCount: children.length, | ||
| itemBuilder: (_, int idx) => children[idx], | ||
| ), | ||
| // Define a default secondaryBody. | ||
| secondaryBody: (_) => | ||
| Container(color: const Color.fromARGB(255, 234, 158, 192)), | ||
| // Override the default secondaryBody during the smallBreakpoint to be | ||
| // empty. Must use AdaptiveScaffold.emptyBuilder to ensure it is properly | ||
| // overridden. | ||
| smallSecondaryBody: AdaptiveScaffold.emptyBuilder)); | ||
| ], | ||
| body: (_) => GridView.count(crossAxisCount: 2, children: children), | ||
| smallBody: (_) => ListView.builder( | ||
| itemCount: children.length, | ||
| itemBuilder: (_, int idx) => children[idx], | ||
| ), | ||
| // Define a default secondaryBody. | ||
| secondaryBody: (_) => Container( | ||
| color: const Color.fromARGB(255, 234, 158, 192), | ||
| ), | ||
| // Override the default secondaryBody during the smallBreakpoint to be | ||
| // empty. Must use AdaptiveScaffold.emptyBuilder to ensure it is properly | ||
| // overridden. | ||
| smallSecondaryBody: AdaptiveScaffold.emptyBuilder, | ||
| ); | ||
| } | ||
| // #enddocregion | ||
| // #enddocregion | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's stick with a more standard bug fix notice without the emoji.
Also, see the style guilde for this: https://github.com/flutter/flutter/wiki/Contributing-to-Plugins-and-Packages#changelog-style
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for sending the guide for change log updation. I will do the needful in my future commits.