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:
@@ -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),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user