Skip to content

Commit

Permalink
Fix immutable warning
Browse files Browse the repository at this point in the history
  • Loading branch information
ilteoood committed Apr 24, 2020
1 parent e2c04b0 commit 3294ce0
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 35 deletions.
33 changes: 16 additions & 17 deletions lib/widgets/I18nPlural.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,28 @@ import 'package:flutter/widgets.dart';
import 'package:flutter_i18n/flutter_i18n.dart';

class I18nPlural extends StatelessWidget {
String _key;
Text _child;
int _pluralValue;
final String _key;
final int _pluralValue;
final Text child;
static const _default_text = Text("");

I18nPlural(this._key, this._pluralValue, {child}) {
this._child = child ?? Text("");
}
I18nPlural(this._key, this._pluralValue, {this.child = _default_text});

@override
Widget build(BuildContext context) {
return Text(
FlutterI18n.plural(context, _key, _pluralValue),
key: _child.key,
style: _child.style,
strutStyle: _child.strutStyle,
textAlign: _child.textAlign,
textDirection: _child.textDirection,
softWrap: _child.softWrap,
overflow: _child.overflow,
textScaleFactor: _child.textScaleFactor,
maxLines: _child.maxLines,
semanticsLabel: _child.semanticsLabel,
textWidthBasis: _child.textWidthBasis,
key: child.key,
style: child.style,
strutStyle: child.strutStyle,
textAlign: child.textAlign,
textDirection: child.textDirection,
softWrap: child.softWrap,
overflow: child.overflow,
textScaleFactor: child.textScaleFactor,
maxLines: child.maxLines,
semanticsLabel: child.semanticsLabel,
textWidthBasis: child.textWidthBasis,
);
}
}
36 changes: 18 additions & 18 deletions lib/widgets/I18nText.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,31 @@ import 'package:flutter/widgets.dart';
import 'package:flutter_i18n/flutter_i18n.dart';

class I18nText extends StatelessWidget {
String _key;
Text _child;
String fallbackKey;
Map<String, String> translationParams;
final String _key;
final Text child;
final String fallbackKey;
final Map<String, String> translationParams;
static const _default_text = Text("");

I18nText(this._key, {child, this.fallbackKey, this.translationParams}) {
this._child = child ?? Text("");
}
I18nText(this._key,
{this.child = _default_text, this.fallbackKey, this.translationParams});

@override
Widget build(BuildContext context) {
return Text(
FlutterI18n.translate(context, _key,
fallbackKey: fallbackKey, translationParams: translationParams),
key: _child.key,
style: _child.style,
strutStyle: _child.strutStyle,
textAlign: _child.textAlign,
textDirection: _child.textDirection,
softWrap: _child.softWrap,
overflow: _child.overflow,
textScaleFactor: _child.textScaleFactor,
maxLines: _child.maxLines,
semanticsLabel: _child.semanticsLabel,
textWidthBasis: _child.textWidthBasis,
key: child.key,
style: child.style,
strutStyle: child.strutStyle,
textAlign: child.textAlign,
textDirection: child.textDirection,
softWrap: child.softWrap,
overflow: child.overflow,
textScaleFactor: child.textScaleFactor,
maxLines: child.maxLines,
semanticsLabel: child.semanticsLabel,
textWidthBasis: child.textWidthBasis,
);
}
}

0 comments on commit 3294ce0

Please sign in to comment.