mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 13:58:47 +00:00
Migrate platform_channels to Material 3 (#1623)
* Migrate platform_channels to Material 3 * fix tests --------- Co-authored-by: Brett Morgan <brettmorgan@google.com>
This commit is contained in:
@@ -25,6 +25,7 @@ class PlatformChannelSample extends StatelessWidget {
|
|||||||
snackBarTheme: SnackBarThemeData(
|
snackBarTheme: SnackBarThemeData(
|
||||||
backgroundColor: Colors.blue[500],
|
backgroundColor: Colors.blue[500],
|
||||||
),
|
),
|
||||||
|
useMaterial3: true,
|
||||||
),
|
),
|
||||||
routerConfig: router(),
|
routerConfig: router(),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import 'package:flutter/services.dart';
|
|||||||
import 'package:platform_channels/src/counter_method_channel.dart';
|
import 'package:platform_channels/src/counter_method_channel.dart';
|
||||||
|
|
||||||
/// The widget demonstrates how to use [MethodChannel] to invoke platform methods.
|
/// The widget demonstrates how to use [MethodChannel] to invoke platform methods.
|
||||||
/// It has two [ElevatedButton]s to increment and decrement the value of
|
/// It has two [FilledButton]s to increment and decrement the value of
|
||||||
/// [count], and a [Text] widget to display its value.
|
/// [count], and a [Text] widget to display its value.
|
||||||
class MethodChannelDemo extends StatefulWidget {
|
class MethodChannelDemo extends StatefulWidget {
|
||||||
const MethodChannelDemo({super.key});
|
const MethodChannelDemo({super.key});
|
||||||
@@ -38,9 +38,9 @@ class _MethodChannelDemoState extends State<MethodChannelDemo> {
|
|||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
children: [
|
children: [
|
||||||
// Whenever users press the ElevatedButton, it invokes
|
// Whenever users press the FilledButton, it invokes
|
||||||
// Counter.increment method to increment the value of count.
|
// Counter.increment method to increment the value of count.
|
||||||
ElevatedButton.icon(
|
FilledButton.icon(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
try {
|
try {
|
||||||
final value = await Counter.increment(counterValue: count);
|
final value = await Counter.increment(counterValue: count);
|
||||||
@@ -56,9 +56,9 @@ class _MethodChannelDemoState extends State<MethodChannelDemo> {
|
|||||||
label: const Text('Increment'),
|
label: const Text('Increment'),
|
||||||
),
|
),
|
||||||
|
|
||||||
// Whenever users press the ElevatedButton, it invokes
|
// Whenever users press the FilledButton, it invokes
|
||||||
// Counter.decrement method to decrement the value of count.
|
// Counter.decrement method to decrement the value of count.
|
||||||
ElevatedButton.icon(
|
FilledButton.icon(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
try {
|
try {
|
||||||
final value = await Counter.decrement(counterValue: count);
|
final value = await Counter.decrement(counterValue: count);
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ class _PlatformImageDemoState extends State<PlatformImageDemo> {
|
|||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 16,
|
height: 16,
|
||||||
),
|
),
|
||||||
ElevatedButton(
|
FilledButton(
|
||||||
onPressed: imageData != null
|
onPressed: imageData != null
|
||||||
? null
|
? null
|
||||||
: () {
|
: () {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ void main() {
|
|||||||
expect(find.byType(Image), findsNothing);
|
expect(find.byType(Image), findsNothing);
|
||||||
|
|
||||||
// Tap on ElevatedButton to get Image.
|
// Tap on ElevatedButton to get Image.
|
||||||
await tester.tap(find.byType(ElevatedButton));
|
await tester.tap(find.byType(FilledButton));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
expect(find.byType(Placeholder), findsNothing);
|
expect(find.byType(Placeholder), findsNothing);
|
||||||
|
|||||||
Reference in New Issue
Block a user