Skip to content

Commit

Permalink
Update Flutter version
Browse files Browse the repository at this point in the history
  • Loading branch information
mkobuolys committed Oct 3, 2023
1 parent 0451428 commit 66707f0
Show file tree
Hide file tree
Showing 36 changed files with 72 additions and 102 deletions.
4 changes: 2 additions & 2 deletions assets/markdown/bridge.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ class JsonHelper {
final json = jsonDecode(jsonString)! as Map<String, dynamic>;
return switch (T) {
Customer _ => Customer.fromJson(json) as T,
Order _ => Order.fromJson(json) as T,
const (Customer) => Customer.fromJson(json) as T,
const (Order) => Order.fromJson(json) as T,
_ => throw Exception("Type of '$T' is not supported."),
};
}
Expand Down
6 changes: 3 additions & 3 deletions assets/markdown/builder.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class McChickenPatty extends Ingredient {
name = 'McChicken Patty';
allergens = [
'Wheat',
'Cooked in the same fryer that we use for Buttermilk Crispy Chicken which contains a milk allergen'
'Cooked in the same fryer that we use for Buttermilk Crispy Chicken which contains a milk allergen',
];
}
}
Expand Down Expand Up @@ -192,7 +192,7 @@ class Burger {
_ingredients.map((x) => x.getName()).join(', ');
String getFormattedAllergens() => <String>{
for (final ingredient in _ingredients) ...ingredient.getAllergens()
for (final ingredient in _ingredients) ...ingredient.getAllergens(),
}.join(', ');
String getFormattedPrice() => '\$${_price.toStringAsFixed(2)}';
Expand Down Expand Up @@ -460,7 +460,7 @@ class _BuilderExampleState extends State<BuilderExample> {
BurgerMenuItem(
label: 'McChicken\u00AE',
burgerBuilder: McChickenBuilder(),
)
),
]);
_selectedBurgerMenuItem = _burgerMenuItems[0];
Expand Down
13 changes: 3 additions & 10 deletions assets/markdown/flyweight.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,19 +223,14 @@ class _FlyweightExampleState extends State<FlyweightExample> {
Widget build(BuildContext context) {
return Stack(
children: <Widget>[
for (var shape in _shapesList)
PositionedShapeWrapper(
shape: shape,
),
for (final shape in _shapesList) PositionedShapeWrapper(shape: shape),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
SwitchListTile.adaptive(
title: const Text(
'Use flyweight factory',
style: TextStyle(
fontWeight: FontWeight.bold,
),
style: TextStyle(fontWeight: FontWeight.bold),
),
activeColor: Colors.black,
value: _useFlyweightFactory,
Expand All @@ -246,9 +241,7 @@ class _FlyweightExampleState extends State<FlyweightExample> {
Center(
child: Text(
'Shape instances count: $_shapeInstancesCount',
style: const TextStyle(
fontWeight: FontWeight.bold,
),
style: const TextStyle(fontWeight: FontWeight.bold),
),
),
],
Expand Down
12 changes: 5 additions & 7 deletions assets/markdown/interpreter.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class _InterpreterExampleState extends State<InterpreterExample> {
'20 3 5 * - 2 3 * +',
'1 1 1 1 1 + + + * 2 -',
'123 12 1 - - 12 9 * -',
'9 8 7 6 5 4 3 2 1 + - + - + - + -'
'9 8 7 6 5 4 3 2 1 + - + - + - + -',
];
@override
Expand All @@ -215,10 +215,8 @@ class _InterpreterExampleState extends State<InterpreterExample> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
for (var postfixExpression in _postfixExpressions)
ExpressionSection(
postfixExpression: postfixExpression,
),
for (final postfixExpression in _postfixExpressions)
ExpressionSection(postfixExpression: postfixExpression),
],
),
),
Expand Down Expand Up @@ -279,11 +277,11 @@ class _ExpressionSectionState extends State<ExpressionSection> {
secondChild: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
for (var solutionStep in _solutionSteps)
for (final solutionStep in _solutionSteps)
Text(
solutionStep,
style: Theme.of(context).textTheme.titleSmall,
)
),
],
),
crossFadeState: _solutionSteps.isEmpty
Expand Down
4 changes: 2 additions & 2 deletions assets/markdown/observer.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,9 @@ class _ObserverExampleState extends State<ObserverExample> {
Column(
children: [
for (final stock in _stockEntries.reversed)
StockRow(stock: stock)
StockRow(stock: stock),
],
)
),
],
),
),
Expand Down
2 changes: 1 addition & 1 deletion assets/markdown/proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class _ProxyExampleState extends State<ProxyExample> {
textAlign: TextAlign.center,
),
const SizedBox(height: LayoutConstants.spaceL),
for (var customer in _customerList)
for (final customer in _customerList)
Card(
child: ListTile(
leading: CircleAvatar(
Expand Down
8 changes: 3 additions & 5 deletions assets/markdown/singleton.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class _SingletonExampleState extends State<SingletonExample> {
final List<ExampleStateBase> stateList = [
ExampleState(),
ExampleStateByDefinition.getState(),
ExampleStateWithoutSingleton()
ExampleStateWithoutSingleton(),
];
void _setTextValues([String text = 'Singleton']) {
Expand All @@ -125,14 +125,12 @@ class _SingletonExampleState extends State<SingletonExample> {
),
child: Column(
children: <Widget>[
for (var state in stateList)
for (final state in stateList)
Padding(
padding: const EdgeInsets.only(
bottom: LayoutConstants.paddingL,
),
child: SingletonExampleCard(
text: state.currentText,
),
child: SingletonExampleCard(text: state.currentText),
),
const SizedBox(height: LayoutConstants.spaceL),
PlatformButton(
Expand Down
4 changes: 2 additions & 2 deletions assets/markdown/strategy.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,9 @@ class ShippingOptions extends StatelessWidget {
'Select shipping type:',
style: Theme.of(context).textTheme.titleMedium,
),
for (var i = 0; i < shippingOptions.length; i++)
for (final (i, option) in shippingOptions.indexed)
RadioListTile<int>(
title: Text(shippingOptions[i].label),
title: Text(option.label),
value: i,
groupValue: selectedIndex,
onChanged: onChanged,
Expand Down
4 changes: 2 additions & 2 deletions lib/design_patterns/bridge/json_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class JsonHelper {
final json = jsonDecode(jsonString)! as Map<String, dynamic>;

return switch (T) {
Customer _ => Customer.fromJson(json) as T,
Order _ => Order.fromJson(json) as T,
const (Customer) => Customer.fromJson(json) as T,
const (Order) => Order.fromJson(json) as T,
_ => throw Exception("Type of '$T' is not supported."),
};
}
Expand Down
2 changes: 1 addition & 1 deletion lib/design_patterns/builder/burger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Burger {
_ingredients.map((x) => x.getName()).join(', ');

String getFormattedAllergens() => <String>{
for (final ingredient in _ingredients) ...ingredient.getAllergens()
for (final ingredient in _ingredients) ...ingredient.getAllergens(),
}.join(', ');

String getFormattedPrice() => '\$${_price.toStringAsFixed(2)}';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class McChickenPatty extends Ingredient {
name = 'McChicken Patty';
allergens = [
'Wheat',
'Cooked in the same fryer that we use for Buttermilk Crispy Chicken which contains a milk allergen'
'Cooked in the same fryer that we use for Buttermilk Crispy Chicken which contains a milk allergen',
];
}
}
2 changes: 1 addition & 1 deletion lib/modules/main_menu/widgets/main_menu_header.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class MainMenuHeader extends StatelessWidget {
),
],
),
)
),
],
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ class FactorySelection extends StatelessWidget {
Widget build(BuildContext context) {
return Column(
children: <Widget>[
for (var i = 0; i < widgetsFactoryList.length; i++)
for (final (i, widgetsFactory) in widgetsFactoryList.indexed)
RadioListTile(
title: Text(widgetsFactoryList[i].getTitle()),
title: Text(widgetsFactory.getTitle()),
value: i,
groupValue: selectedIndex,
selected: i == selectedIndex,
Expand Down
5 changes: 1 addition & 4 deletions lib/widgets/design_patterns/adapter/contacts_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,7 @@ class _ContactsSectionContent extends StatelessWidget {
)
: Column(
children: <Widget>[
for (var contact in contacts)
ContactCard(
contact: contact,
)
for (final contact in contacts) ContactCard(contact: contact),
],
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class CustomersDatatable extends StatelessWidget {
),
],
rows: <DataRow>[
for (var customer in customers)
for (final customer in customers)
DataRow(
cells: <DataCell>[
DataCell(Text(customer.name)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class OrdersDatatable extends StatelessWidget {
),
],
rows: <DataRow>[
for (var order in orders)
for (final order in orders)
DataRow(
cells: <DataCell>[
DataCell(Text(order.dishes.join(', '))),
Expand Down
4 changes: 2 additions & 2 deletions lib/widgets/design_patterns/bridge/storage_selection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ class StorageSelection extends StatelessWidget {
Widget build(BuildContext context) {
return Column(
children: <Widget>[
for (var i = 0; i < storages.length; i++)
for (final (i, storage) in storages.indexed)
RadioListTile(
title: Text(storages[i].getTitle()),
title: Text(storage.getTitle()),
value: i,
groupValue: selectedIndex,
selected: i == selectedIndex,
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/design_patterns/builder/builder_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class _BuilderExampleState extends State<BuilderExample> {
BurgerMenuItem(
label: 'McChicken\u00AE',
burgerBuilder: McChickenBuilder(),
)
),
]);

_selectedBurgerMenuItem = _burgerMenuItems[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ class LogMessagesColumn extends StatelessWidget {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
for (var logMessage in logMessages)
for (final logMessage in logMessages)
Row(
children: <Widget>[
Expanded(
child: logMessage.getFormattedMessage(),
),
Expanded(child: logMessage.getFormattedMessage()),
],
)
),
],
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@ class CommandHistoryColumn extends StatelessWidget {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'Command history:',
style: Theme.of(context).textTheme.titleLarge,
),
Text('Command history:', style: Theme.of(context).textTheme.titleLarge),
const SizedBox(height: LayoutConstants.spaceS),
if (commandList.isEmpty) const Text('Command history is empty.'),
for (var i = 0; i < commandList.length; i++)
Text('${i + 1}. ${commandList[i]}'),
for (final (i, command) in commandList.indexed)
Text('${i + 1}. $command'),
],
);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/widgets/design_patterns/decorator/pizza_selection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ class PizzaSelection extends StatelessWidget {
Widget build(BuildContext context) {
return Column(
children: <Widget>[
for (var i = 0; i < _labels.length; i++)
for (final (i, label) in _labels.indexed)
RadioListTile(
title: Text(_labels[i]),
title: Text(label),
value: i,
groupValue: selectedIndex,
selected: i == selectedIndex,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ class DialogSelection extends StatelessWidget {
Widget build(BuildContext context) {
return Column(
children: <Widget>[
for (var i = 0; i < customDialogList.length; i++)
for (final (i, dialog) in customDialogList.indexed)
RadioListTile(
title: Text(customDialogList[i].getTitle()),
title: Text(dialog.getTitle()),
value: i,
groupValue: selectedIndex,
selected: i == selectedIndex,
Expand Down
13 changes: 3 additions & 10 deletions lib/widgets/design_patterns/flyweight/flyweight_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,14 @@ class _FlyweightExampleState extends State<FlyweightExample> {
Widget build(BuildContext context) {
return Stack(
children: <Widget>[
for (var shape in _shapesList)
PositionedShapeWrapper(
shape: shape,
),
for (final shape in _shapesList) PositionedShapeWrapper(shape: shape),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
SwitchListTile.adaptive(
title: const Text(
'Use flyweight factory',
style: TextStyle(
fontWeight: FontWeight.bold,
),
style: TextStyle(fontWeight: FontWeight.bold),
),
activeColor: Colors.black,
value: _useFlyweightFactory,
Expand All @@ -92,9 +87,7 @@ class _FlyweightExampleState extends State<FlyweightExample> {
Center(
child: Text(
'Shape instances count: $_shapeInstancesCount',
style: const TextStyle(
fontWeight: FontWeight.bold,
),
style: const TextStyle(fontWeight: FontWeight.bold),
),
),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ class _ExpressionSectionState extends State<ExpressionSection> {
secondChild: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
for (var solutionStep in _solutionSteps)
for (final solutionStep in _solutionSteps)
Text(
solutionStep,
style: Theme.of(context).textTheme.titleSmall,
)
),
],
),
crossFadeState: _solutionSteps.isEmpty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class _InterpreterExampleState extends State<InterpreterExample> {
'20 3 5 * - 2 3 * +',
'1 1 1 1 1 + + + * 2 -',
'123 12 1 - - 12 9 * -',
'9 8 7 6 5 4 3 2 1 + - + - + - + -'
'9 8 7 6 5 4 3 2 1 + - + - + - + -',
];

@override
Expand All @@ -29,10 +29,8 @@ class _InterpreterExampleState extends State<InterpreterExample> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
for (var postfixExpression in _postfixExpressions)
ExpressionSection(
postfixExpression: postfixExpression,
),
for (final postfixExpression in _postfixExpressions)
ExpressionSection(postfixExpression: postfixExpression),
],
),
),
Expand Down
Loading

0 comments on commit 66707f0

Please sign in to comment.