Unverified Commit 2ecf4ae9 authored by Greg Spencer's avatar Greg Spencer Committed by GitHub

Update the counter app to enable Material 3 (#118835)

* Update the counter app to enable Material 3

* Fix tools tests

* Update some wording

* Revert all but useMaterial3

* Update comments
parent 4c99da6c
...@@ -49,14 +49,21 @@ class MyApp extends StatelessWidget { ...@@ -49,14 +49,21 @@ class MyApp extends StatelessWidget {
theme: ThemeData( theme: ThemeData(
// This is the theme of your application. // This is the theme of your application.
// //
// Try running your application with "flutter run". You'll see the // TRY THIS: Try running your application with "flutter run". You'll see
// application has a blue toolbar. Then, without quitting the app, try // the application has a blue toolbar. Then, without quitting the app,
// changing the primarySwatch below to Colors.green and then invoke // try changing the seedColor in the colorScheme below to Colors.green
// "hot reload" (press "r" in the console where you ran "flutter run", // and then invoke "hot reload" (save your changes or press the "hot
// or simply save your changes to "hot reload" in a Flutter IDE). // reload" button in a Flutter-supported IDE, or press "r" if you used
// the command line to start the app).
//
// Notice that the counter didn't reset back to zero; the application // Notice that the counter didn't reset back to zero; the application
// is not restarted. // state is not lost during the reload. To reset the state, use hot
primarySwatch: Colors.blue, // restart instead.
//
// This works for code too, not just values: Most code changes can be
// tested with just a hot reload.
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
), ),
home: const MyHomePage(title: 'Flutter Demo Home Page'), home: const MyHomePage(title: 'Flutter Demo Home Page'),
); );
...@@ -105,6 +112,10 @@ class _MyHomePageState extends State<MyHomePage> { ...@@ -105,6 +112,10 @@ class _MyHomePageState extends State<MyHomePage> {
// than having to individually change instances of widgets. // than having to individually change instances of widgets.
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
// TRY THIS: Try changing the color here to a specific color (to
// Colors.amber, perhaps?) and trigger a hot reload to see the AppBar
// change color while the other colors stay the same.
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
// Here we take the value from the MyHomePage object that was created by // Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title. // the App.build method, and use it to set our appbar title.
title: Text(widget.title), title: Text(widget.title),
...@@ -117,16 +128,15 @@ class _MyHomePageState extends State<MyHomePage> { ...@@ -117,16 +128,15 @@ class _MyHomePageState extends State<MyHomePage> {
// arranges them vertically. By default, it sizes itself to fit its // arranges them vertically. By default, it sizes itself to fit its
// children horizontally, and tries to be as tall as its parent. // children horizontally, and tries to be as tall as its parent.
// //
// Invoke "debug painting" (press "p" in the console, choose the
// "Toggle Debug Paint" action from the Flutter Inspector in Android
// Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
// to see the wireframe for each widget.
//
// Column has various properties to control how it sizes itself and // Column has various properties to control how it sizes itself and
// how it positions its children. Here we use mainAxisAlignment to // how it positions its children. Here we use mainAxisAlignment to
// center the children vertically; the main axis here is the vertical // center the children vertically; the main axis here is the vertical
// axis because Columns are vertical (the cross axis would be // axis because Columns are vertical (the cross axis would be
// horizontal). // horizontal).
//
// TRY THIS: Invoke "debug painting" (choose the "Toggle Debug Paint"
// action in the IDE, or press "p" in the console), to see the
// wireframe for each widget.
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[ children: <Widget>[
const Text( const Text(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment