1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-08 22:09:06 +00:00

Landing beta changes in master for the new stable release (#747)

This commit is contained in:
Andrew Brogdon
2021-03-03 11:44:35 -08:00
committed by GitHub
parent 6c81510d6e
commit 8c1cd0b049
101 changed files with 1006 additions and 1040 deletions

View File

@@ -22,70 +22,66 @@ class _MethodChannelDemoState extends State<MethodChannelDemo> {
appBar: AppBar(
title: const Text('MethodChannel Demo'),
),
body: Builder(
builder: (context) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Value of count is $count',
style: Theme.of(context).textTheme.headline5,
),
SizedBox(
height: 16,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text(
'Value of count is $count',
style: Theme.of(context).textTheme.headline5,
// Whenever users press the ElevatedButton, it invokes
// Counter.increment method to increment the value of count.
ElevatedButton.icon(
onPressed: () async {
try {
final value = await Counter.increment(counterValue: count);
setState(() => count = value);
} catch (error) {
showErrorMessage(
context,
error.message as String,
);
}
},
icon: Icon(Icons.add),
label: Text('Increment'),
),
SizedBox(
height: 16,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
// Whenever users press the ElevatedButton, it invokes
// Counter.increment method to increment the value of count.
ElevatedButton.icon(
onPressed: () async {
try {
final value =
await Counter.increment(counterValue: count);
setState(() => count = value);
} catch (error) {
showErrorMessage(
context,
error.message as String,
);
}
},
icon: Icon(Icons.add),
label: Text('Increment'),
),
// Whenever users press the ElevatedButton, it invokes
// Counter.decrement method to decrement the value of count.
ElevatedButton.icon(
onPressed: () async {
try {
final value =
await Counter.decrement(counterValue: count);
setState(() => count = value);
} catch (error) {
showErrorMessage(
context,
error.message as String,
);
}
},
icon: Icon(Icons.remove),
label: Text('Decrement'),
)
],
// Whenever users press the ElevatedButton, it invokes
// Counter.decrement method to decrement the value of count.
ElevatedButton.icon(
onPressed: () async {
try {
final value = await Counter.decrement(counterValue: count);
setState(() => count = value);
} catch (error) {
showErrorMessage(
context,
error.message as String,
);
}
},
icon: Icon(Icons.remove),
label: Text('Decrement'),
)
],
);
},
)
],
),
);
}
void showErrorMessage(BuildContext context, String errorMessage) {
Scaffold.of(context).showSnackBar(SnackBar(
content: Text(errorMessage),
));
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(errorMessage),
),
);
}
}