Auto-format Framework (#160545)
This auto-formats all *.dart files in the repository outside of the `engine` subdirectory and enforces that these files stay formatted with a presubmit check. **Reviewers:** Please carefully review all the commits except for the one titled "formatted". The "formatted" commit was auto-generated by running `dev/tools/format.sh -a -f`. The other commits were hand-crafted to prepare the repo for the formatting change. I recommend reviewing the commits one-by-one via the "Commits" tab and avoiding Github's "Files changed" tab as it will likely slow down your browser because of the size of this PR. --------- Co-authored-by: Kate Lovett <katelovett@google.com> Co-authored-by: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
8e0993eda8
commit
5491c8c146
@@ -13,10 +13,7 @@ class NavigationBarApp extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
theme: ThemeData(useMaterial3: true),
|
||||
home: const NavigationExample(),
|
||||
);
|
||||
return MaterialApp(theme: ThemeData(useMaterial3: true), home: const NavigationExample());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,92 +50,89 @@ class _NavigationExampleState extends State<NavigationExample> {
|
||||
label: 'Notifications',
|
||||
),
|
||||
NavigationDestination(
|
||||
icon: Badge(
|
||||
label: Text('2'),
|
||||
child: Icon(Icons.messenger_sharp),
|
||||
),
|
||||
icon: Badge(label: Text('2'), child: Icon(Icons.messenger_sharp)),
|
||||
label: 'Messages',
|
||||
),
|
||||
],
|
||||
),
|
||||
body: <Widget>[
|
||||
/// Home page
|
||||
Card(
|
||||
shadowColor: Colors.transparent,
|
||||
margin: const EdgeInsets.all(8.0),
|
||||
child: SizedBox.expand(
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Home page',
|
||||
style: theme.textTheme.titleLarge,
|
||||
body:
|
||||
<Widget>[
|
||||
/// Home page
|
||||
Card(
|
||||
shadowColor: Colors.transparent,
|
||||
margin: const EdgeInsets.all(8.0),
|
||||
child: SizedBox.expand(
|
||||
child: Center(child: Text('Home page', style: theme.textTheme.titleLarge)),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
/// Notifications page
|
||||
const Padding(
|
||||
padding: EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Card(
|
||||
child: ListTile(
|
||||
leading: Icon(Icons.notifications_sharp),
|
||||
title: Text('Notification 1'),
|
||||
subtitle: Text('This is a notification'),
|
||||
),
|
||||
),
|
||||
Card(
|
||||
child: ListTile(
|
||||
leading: Icon(Icons.notifications_sharp),
|
||||
title: Text('Notification 2'),
|
||||
subtitle: Text('This is a notification'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
/// Messages page
|
||||
ListView.builder(
|
||||
reverse: true,
|
||||
itemCount: 2,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
if (index == 0) {
|
||||
return Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: Container(
|
||||
margin: const EdgeInsets.all(8.0),
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.primary,
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
|
||||
/// Notifications page
|
||||
const Padding(
|
||||
padding: EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Card(
|
||||
child: ListTile(
|
||||
leading: Icon(Icons.notifications_sharp),
|
||||
title: Text('Notification 1'),
|
||||
subtitle: Text('This is a notification'),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
'Hello',
|
||||
style: theme.textTheme.bodyLarge!
|
||||
.copyWith(color: theme.colorScheme.onPrimary),
|
||||
Card(
|
||||
child: ListTile(
|
||||
leading: Icon(Icons.notifications_sharp),
|
||||
title: Text('Notification 2'),
|
||||
subtitle: Text('This is a notification'),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
return Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Container(
|
||||
margin: const EdgeInsets.all(8.0),
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.primary,
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
),
|
||||
child: Text(
|
||||
'Hi!',
|
||||
style: theme.textTheme.bodyLarge!
|
||||
.copyWith(color: theme.colorScheme.onPrimary),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
][currentPageIndex],
|
||||
),
|
||||
|
||||
/// Messages page
|
||||
ListView.builder(
|
||||
reverse: true,
|
||||
itemCount: 2,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
if (index == 0) {
|
||||
return Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: Container(
|
||||
margin: const EdgeInsets.all(8.0),
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.primary,
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
),
|
||||
child: Text(
|
||||
'Hello',
|
||||
style: theme.textTheme.bodyLarge!.copyWith(
|
||||
color: theme.colorScheme.onPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
return Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Container(
|
||||
margin: const EdgeInsets.all(8.0),
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.primary,
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
),
|
||||
child: Text(
|
||||
'Hi!',
|
||||
style: theme.textTheme.bodyLarge!.copyWith(
|
||||
color: theme.colorScheme.onPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
][currentPageIndex],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,14 +40,8 @@ class _NavigationExampleState extends State<NavigationExample> {
|
||||
});
|
||||
},
|
||||
destinations: const <Widget>[
|
||||
NavigationDestination(
|
||||
icon: Icon(Icons.explore),
|
||||
label: 'Explore',
|
||||
),
|
||||
NavigationDestination(
|
||||
icon: Icon(Icons.commute),
|
||||
label: 'Commute',
|
||||
),
|
||||
NavigationDestination(icon: Icon(Icons.explore), label: 'Explore'),
|
||||
NavigationDestination(icon: Icon(Icons.commute), label: 'Commute'),
|
||||
NavigationDestination(
|
||||
selectedIcon: Icon(Icons.bookmark),
|
||||
icon: Icon(Icons.bookmark_border),
|
||||
|
||||
@@ -32,43 +32,42 @@ class _HomeState extends State<Home> with TickerProviderStateMixin<Home> {
|
||||
int selectedIndex = 0;
|
||||
|
||||
AnimationController buildFaderController() {
|
||||
return AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(milliseconds: 300),
|
||||
)..addStatusListener((AnimationStatus status) {
|
||||
if (status.isDismissed) {
|
||||
setState(() {}); // Rebuild unselected destinations offstage.
|
||||
}
|
||||
});
|
||||
return AnimationController(vsync: this, duration: const Duration(milliseconds: 300))
|
||||
..addStatusListener((AnimationStatus status) {
|
||||
if (status.isDismissed) {
|
||||
setState(() {}); // Rebuild unselected destinations offstage.
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
navigatorKeys = List<GlobalKey<NavigatorState>>.generate(
|
||||
allDestinations.length,
|
||||
(int index) => GlobalKey(),
|
||||
).toList();
|
||||
navigatorKeys =
|
||||
List<GlobalKey<NavigatorState>>.generate(
|
||||
allDestinations.length,
|
||||
(int index) => GlobalKey(),
|
||||
).toList();
|
||||
|
||||
destinationFaders = List<AnimationController>.generate(
|
||||
allDestinations.length,
|
||||
(int index) => buildFaderController(),
|
||||
).toList();
|
||||
destinationFaders =
|
||||
List<AnimationController>.generate(
|
||||
allDestinations.length,
|
||||
(int index) => buildFaderController(),
|
||||
).toList();
|
||||
destinationFaders[selectedIndex].value = 1.0;
|
||||
|
||||
final CurveTween tween = CurveTween(curve: Curves.fastOutSlowIn);
|
||||
destinationViews = allDestinations.map<Widget>(
|
||||
(Destination destination) {
|
||||
return FadeTransition(
|
||||
opacity: destinationFaders[destination.index].drive(tween),
|
||||
child: DestinationView(
|
||||
destination: destination,
|
||||
navigatorKey: navigatorKeys[destination.index],
|
||||
),
|
||||
);
|
||||
},
|
||||
).toList();
|
||||
destinationViews =
|
||||
allDestinations.map<Widget>((Destination destination) {
|
||||
return FadeTransition(
|
||||
opacity: destinationFaders[destination.index].drive(tween),
|
||||
child: DestinationView(
|
||||
destination: destination,
|
||||
navigatorKey: navigatorKeys[destination.index],
|
||||
),
|
||||
);
|
||||
}).toList();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -91,22 +90,21 @@ class _HomeState extends State<Home> with TickerProviderStateMixin<Home> {
|
||||
top: false,
|
||||
child: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: allDestinations.map(
|
||||
(Destination destination) {
|
||||
final int index = destination.index;
|
||||
final Widget view = destinationViews[index];
|
||||
if (index == selectedIndex) {
|
||||
destinationFaders[index].forward();
|
||||
return Offstage(offstage: false, child: view);
|
||||
} else {
|
||||
destinationFaders[index].reverse();
|
||||
if (destinationFaders[index].isAnimating) {
|
||||
return IgnorePointer(child: view);
|
||||
children:
|
||||
allDestinations.map((Destination destination) {
|
||||
final int index = destination.index;
|
||||
final Widget view = destinationViews[index];
|
||||
if (index == selectedIndex) {
|
||||
destinationFaders[index].forward();
|
||||
return Offstage(offstage: false, child: view);
|
||||
} else {
|
||||
destinationFaders[index].reverse();
|
||||
if (destinationFaders[index].isAnimating) {
|
||||
return IgnorePointer(child: view);
|
||||
}
|
||||
return Offstage(child: view);
|
||||
}
|
||||
return Offstage(child: view);
|
||||
}
|
||||
},
|
||||
).toList(),
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
bottomNavigationBar: NavigationBar(
|
||||
@@ -116,14 +114,13 @@ class _HomeState extends State<Home> with TickerProviderStateMixin<Home> {
|
||||
selectedIndex = index;
|
||||
});
|
||||
},
|
||||
destinations: allDestinations.map<NavigationDestination>(
|
||||
(Destination destination) {
|
||||
return NavigationDestination(
|
||||
icon: Icon(destination.icon, color: destination.color),
|
||||
label: destination.title,
|
||||
);
|
||||
},
|
||||
).toList(),
|
||||
destinations:
|
||||
allDestinations.map<NavigationDestination>((Destination destination) {
|
||||
return NavigationDestination(
|
||||
icon: Icon(destination.icon, color: destination.color),
|
||||
label: destination.title,
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -190,11 +187,7 @@ class RootPage extends StatelessWidget {
|
||||
ElevatedButton(
|
||||
style: buttonStyle,
|
||||
onPressed: () {
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
useRootNavigator: false,
|
||||
builder: _buildDialog,
|
||||
);
|
||||
showDialog<void>(context: context, useRootNavigator: false, builder: _buildDialog);
|
||||
},
|
||||
child: const Text('Local Dialog'),
|
||||
),
|
||||
@@ -256,9 +249,7 @@ class ListPage extends StatelessWidget {
|
||||
final ButtonStyle buttonStyle = OutlinedButton.styleFrom(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
side: BorderSide(
|
||||
color: colorScheme.onSurface.withOpacity(0.12),
|
||||
),
|
||||
side: BorderSide(color: colorScheme.onSurface.withOpacity(0.12)),
|
||||
),
|
||||
foregroundColor: destination.color,
|
||||
fixedSize: const Size.fromHeight(64),
|
||||
@@ -280,11 +271,7 @@ class ListPage extends StatelessWidget {
|
||||
child: OutlinedButton(
|
||||
style: buttonStyle.copyWith(
|
||||
backgroundColor: WidgetStatePropertyAll<Color>(
|
||||
Color.lerp(
|
||||
destination.color[100],
|
||||
Colors.white,
|
||||
index / itemCount
|
||||
)!,
|
||||
Color.lerp(destination.color[100], Colors.white, index / itemCount)!,
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
@@ -339,15 +326,10 @@ class _TextPageState extends State<TextPage> {
|
||||
alignment: Alignment.center,
|
||||
child: TextField(
|
||||
controller: textController,
|
||||
style: theme.primaryTextTheme.headlineMedium?.copyWith(
|
||||
color: widget.destination.color,
|
||||
),
|
||||
style: theme.primaryTextTheme.headlineMedium?.copyWith(color: widget.destination.color),
|
||||
decoration: InputDecoration(
|
||||
focusedBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: widget.destination.color,
|
||||
width: 3.0,
|
||||
),
|
||||
borderSide: BorderSide(color: widget.destination.color, width: 3.0),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -357,11 +339,7 @@ class _TextPageState extends State<TextPage> {
|
||||
}
|
||||
|
||||
class DestinationView extends StatefulWidget {
|
||||
const DestinationView({
|
||||
super.key,
|
||||
required this.destination,
|
||||
required this.navigatorKey,
|
||||
});
|
||||
const DestinationView({super.key, required this.destination, required this.navigatorKey});
|
||||
|
||||
final Destination destination;
|
||||
final Key navigatorKey;
|
||||
|
||||
Reference in New Issue
Block a user