-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
158 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
notes/flutter_web/lib/routes/notes/cheatsheets/widgets/_examples/Navigation_AppBar.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:you_flutter/state.dart'; | ||
|
||
main() { | ||
runApp(MaterialApp(home: Navigation_AppBar())); | ||
} | ||
|
||
// ignore: camel_case_types | ||
class Navigation_AppBar extends StatelessWidget { | ||
Navigation_AppBar({super.key}); | ||
|
||
final pinned = true.signal(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final colors = Theme.of(context).colorScheme; | ||
|
||
return Scaffold( | ||
appBar: AppBar(backgroundColor: colors.surfaceContainerHighest, leading: const BackButton(), actions: [ | ||
IconButton(icon: const Icon(Icons.minimize), onPressed: () {}), | ||
IconButton(icon: const Icon(Icons.filter_alt_off), onPressed: () {}), | ||
]), | ||
body: const Text("Hello\nWorld"), | ||
); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
notes/flutter_web/lib/routes/notes/cheatsheets/widgets/_examples/Navigation_Menu.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
main() { | ||
runApp(const MaterialApp(home: Scaffold(body: Navigation_Menu()))); | ||
} | ||
|
||
// ignore: camel_case_types | ||
class Navigation_Menu extends StatelessWidget { | ||
const Navigation_Menu({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return MenuAnchor( | ||
builder: (context, controller, child) { | ||
return FilledButton.tonal( | ||
onPressed: () { | ||
if (controller.isOpen) { | ||
controller.close(); | ||
} else { | ||
controller.open(); | ||
} | ||
}, | ||
child: const Text('Show menu'), | ||
); | ||
}, | ||
menuChildren: [ | ||
MenuItemButton(leadingIcon: const Icon(Icons.people_alt_outlined), child: const Text('Item 1'), onPressed: () {}), | ||
MenuItemButton(leadingIcon: const Icon(Icons.remove_red_eye_outlined), child: const Text('Item 2'), onPressed: () {}), | ||
MenuItemButton(leadingIcon: const Icon(Icons.refresh), child: const Text('Item 3'), onPressed: () {}), | ||
], | ||
); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
...s/flutter_web/lib/routes/notes/cheatsheets/widgets/_examples/Navigation_SliverAppBar.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:you_flutter/state.dart'; | ||
|
||
main() { | ||
runApp(MaterialApp(home: Scaffold(body: Navigation_SliverAppBar()))); | ||
} | ||
|
||
// ignore: camel_case_types | ||
class Navigation_SliverAppBar extends StatelessWidget { | ||
Navigation_SliverAppBar({super.key}); | ||
|
||
final pinned = true.signal(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Watch(builder: (context) { | ||
return CustomScrollView( | ||
slivers: <Widget>[ | ||
SliverAppBar( | ||
pinned: pinned.value, | ||
expandedHeight: 180.0, | ||
actions: [ | ||
Row(children: [const Text('pinned'), Switch(onChanged: (newValue) => pinned.value = newValue, value: pinned.value)]), | ||
], | ||
flexibleSpace: const FlexibleSpaceBar(background: FlutterLogo()), | ||
), | ||
const SliverToBoxAdapter(child: Text('Try Scroll to see effect.')), | ||
SliverList( | ||
delegate: SliverChildBuilderDelegate( | ||
(BuildContext context, int index) { | ||
return Container( | ||
color: index.isOdd ? Colors.white : Colors.black12, | ||
height: 50.0, | ||
child: Center( | ||
child: Text('$index', textScaler: const TextScaler.linear(2)), | ||
), | ||
); | ||
}, | ||
childCount: 10, | ||
), | ||
), | ||
], | ||
); | ||
}); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
notes/flutter_web/lib/routes/notes/cheatsheets/widgets/_examples/Navigation_TabBar.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
main() { | ||
runApp(const MaterialApp(home: Scaffold(body: Navigation_TabBar()))); | ||
} | ||
|
||
// ignore: camel_case_types | ||
class Navigation_TabBar extends StatelessWidget { | ||
const Navigation_TabBar({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
List<({Tab tab, Widget page})> tabs = [ | ||
( | ||
tab: const Tab(icon: Icon(Icons.cloud_outlined), iconMargin: EdgeInsets.all(10)), | ||
page: const Center(child: Text("It's cloudy here")), | ||
), | ||
( | ||
tab: const Tab(icon: Icon(Icons.beach_access_sharp), iconMargin: EdgeInsets.all(10)), | ||
page: const Center(child: Text("It's rainy here")), | ||
), | ||
( | ||
tab: const Tab(icon: Icon(Icons.brightness_5_sharp), iconMargin: EdgeInsets.all(10)), | ||
page: const Center(child: Text("It's sunny here")), | ||
), | ||
]; | ||
|
||
return DefaultTabController( | ||
initialIndex: 1, | ||
length: tabs.length, | ||
child: Column(children: [ | ||
TabBar(tabs: tabs.map((e) => e.tab).toList()), | ||
SizedBox( | ||
height: 100, | ||
child: TabBarView(children: tabs.map((e) => e.page).toList()), | ||
) | ||
]), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters