diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index 584c109..4a0c122 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -13,8 +13,7 @@ additional functionality it is fine to subclass or reimplement FlutterApplication and put your custom class here. --> + + + diff --git a/example/android/app/src/main/java/net/demo/languagepickersdemo/MainActivity.java b/example/android/app/src/main/java/net/demo/languagepickersdemo/MainActivity.java index 6aed9c9..268b759 100644 --- a/example/android/app/src/main/java/net/demo/languagepickersdemo/MainActivity.java +++ b/example/android/app/src/main/java/net/demo/languagepickersdemo/MainActivity.java @@ -7,7 +7,5 @@ public class MainActivity extends FlutterActivity { @Override protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - GeneratedPluginRegistrant.registerWith(this); } } diff --git a/lib/language_picker_cupertino.dart b/lib/language_picker_cupertino.dart index f9b697d..fafba4c 100644 --- a/lib/language_picker_cupertino.dart +++ b/lib/language_picker_cupertino.dart @@ -9,11 +9,11 @@ const double defaultPickerItemHeight = 32.0; /// in cupertino style class LanguagePickerCupertino extends StatefulWidget { /// Callback that is called with selected Language - final ValueChanged onValuePicked; + final ValueChanged? onValuePicked; ///Callback that is called with selected item of type Language which returns a ///Widget to build list view item inside dialog - final ItemBuilder itemBuilder; + final ItemBuilder? itemBuilder; ///The [itemExtent] of [CupertinoPicker] /// The uniform height of all children. @@ -26,7 +26,7 @@ class LanguagePickerCupertino extends StatefulWidget { final double pickerSheetHeight; ///The TextStyle that is applied to Text widgets inside item - final TextStyle textStyle; + final TextStyle? textStyle; /// Relative ratio between this picker's height and the simulated cylinder's diameter. /// @@ -35,7 +35,7 @@ class LanguagePickerCupertino extends StatefulWidget { /// For more details, see [ListWheelScrollView.diameterRatio]. /// /// Must not be null and defaults to `1.1` to visually mimic iOS. - final double diameterRatio; + final double? diameterRatio; /// Background color behind the children. /// @@ -43,27 +43,27 @@ class LanguagePickerCupertino extends StatefulWidget { /// /// This can be set to null to disable the background painting entirely; this /// is mildly more efficient than using [Colors.transparent]. - final Color backgroundColor; + final Color? backgroundColor; /// {@macro flutter.rendering.wheelList.offAxisFraction} - final double offAxisFraction; + final double? offAxisFraction; /// {@macro flutter.rendering.wheelList.useMagnifier} - final bool useMagnifier; + final bool? useMagnifier; /// {@macro flutter.rendering.wheelList.magnification} - final double magnification; + final double? magnification; /// A [FixedExtentScrollController] to read and control the current item. /// /// If null, an implicit one will be created internally. - final FixedExtentScrollController scrollController; + final FixedExtentScrollController? scrollController; /// List of languages available in this picker. - final List> languagesList; + final List>? languagesList; const LanguagePickerCupertino({ - Key key, + Key? key, this.onValuePicked, this.itemBuilder, this.pickerItemHeight = defaultPickerItemHeight, @@ -83,7 +83,7 @@ class LanguagePickerCupertino extends StatefulWidget { } class _CupertinoLanguagePickerState extends State { - List _allLanguages; + late List _allLanguages; @override void initState() { @@ -124,11 +124,11 @@ class _CupertinoLanguagePickerState extends State { backgroundColor: CupertinoColors.white, children: _allLanguages .map((Language language) => widget.itemBuilder != null - ? widget.itemBuilder(language) + ? widget.itemBuilder!(language) : _buildDefaultItem(language)) .toList(), onSelectedItemChanged: (int index) { - widget.onValuePicked(_allLanguages[index]); + widget.onValuePicked!(_allLanguages[index]); }, ); } diff --git a/lib/language_picker_dialog.dart b/lib/language_picker_dialog.dart index 8b269db..3712c40 100644 --- a/lib/language_picker_dialog.dart +++ b/lib/language_picker_dialog.dart @@ -11,13 +11,13 @@ import 'languages.dart'; class LanguagePickerDialog extends StatefulWidget { /// Callback that is called with selected Language - final ValueChanged onValuePicked; + final ValueChanged? onValuePicked; /// The (optional) title of the dialog is displayed in a large font at the top /// of the dialog. /// /// Typically a [Text] widget. - final Widget title; + final Widget? title; /// Padding around the title. /// @@ -29,7 +29,7 @@ class LanguagePickerDialog extends StatefulWidget { /// provided (but see [contentPadding]). If it _is_ null, then an extra 20 /// pixels of bottom padding is added to separate the [title] from the /// [actions]. - final EdgeInsetsGeometry titlePadding; + final EdgeInsetsGeometry? titlePadding; /// Padding around the content. @@ -46,11 +46,11 @@ class LanguagePickerDialog extends StatefulWidget { /// /// * [SemanticsConfiguration.isRouteName], for a description of how this /// value is used. - final String semanticLabel; + final String? semanticLabel; ///Callback that is called with selected item of type Language which returns a ///Widget to build list view item inside dialog - final ItemBuilder itemBuilder; + final ItemBuilder? itemBuilder; /// The (optional) horizontal separator used between title, content and /// actions. @@ -67,19 +67,19 @@ class LanguagePickerDialog extends StatefulWidget { final bool isSearchable; /// The optional [decoration] of search [TextField] - final InputDecoration searchInputDecoration; + final InputDecoration? searchInputDecoration; ///The optional [cursorColor] of search [TextField] - final Color searchCursorColor; + final Color? searchCursorColor; ///The search empty view is displayed if nothing returns from search result - final Widget searchEmptyView; + final Widget? searchEmptyView; /// List of languages available in this picker. - final List> languagesList; + final List>? languagesList; LanguagePickerDialog({ - Key key, + Key? key, this.onValuePicked, this.title, this.titlePadding, @@ -104,8 +104,8 @@ class LanguagePickerDialog extends StatefulWidget { } class SingleChoiceDialogState extends State { - List _allLanguages; - List _filteredLanguages; + late List _allLanguages; + late List _filteredLanguages; @override void initState() { @@ -134,10 +134,10 @@ class SingleChoiceDialogState extends State { children: _filteredLanguages .map((item) => SimpleDialogOption( child: widget.itemBuilder != null - ? widget.itemBuilder(item) + ? widget.itemBuilder!(item) : Text(item.name), onPressed: () { - widget.onValuePicked(item); + widget.onValuePicked!(item); Navigator.pop(context); }, )) @@ -163,7 +163,7 @@ class SingleChoiceDialogState extends State { _buildTitle() { return widget.titlePadding != null ? Padding( - padding: widget.titlePadding, + padding: widget.titlePadding!, child: widget.title, ) : widget.title; diff --git a/lib/language_picker_dropdown.dart b/lib/language_picker_dropdown.dart index 55bded7..5cb63cb 100644 --- a/lib/language_picker_dropdown.dart +++ b/lib/language_picker_dropdown.dart @@ -11,25 +11,25 @@ class LanguagePickerDropdown extends StatefulWidget { ///If it is not provided, default one will be used which displays ///flag image, isoCode and phoneCode in a row. ///Check _buildDefaultMenuItem method for details. - final ItemBuilder itemBuilder; + final ItemBuilder? itemBuilder; ///It should be one of the ISO ALPHA-2 Code that is provided ///in languagesList map of languages.dart file. - final String initialValue; + final String? initialValue; ///This function will be called whenever a Language item is selected. - final ValueChanged onValuePicked; + final ValueChanged? onValuePicked; /// List of languages available in this picker. - final List> languagesList; + final List>? languagesList; @override _LanguagePickerDropdownState createState() => _LanguagePickerDropdownState(); } class _LanguagePickerDropdownState extends State { - List _languages; - Language _selectedLanguage; + late List _languages; + late Language _selectedLanguage; @override void initState() { @@ -58,7 +58,7 @@ class _LanguagePickerDropdownState extends State { .map((language) => DropdownMenuItem( value: language, child: widget.itemBuilder != null - ? widget.itemBuilder(language) + ? widget.itemBuilder!(language) : _buildDefaultMenuItem(language))) .toList(); @@ -69,8 +69,8 @@ class _LanguagePickerDropdownState extends State { isDense: true, onChanged: (value) { setState(() { - _selectedLanguage = value; - widget.onValuePicked(value); + _selectedLanguage = value!; + widget.onValuePicked!(value); }); }, items: items, diff --git a/lib/languages.dart b/lib/languages.dart index 75a1e6a..b06e0dc 100644 --- a/lib/languages.dart +++ b/lib/languages.dart @@ -5,8 +5,8 @@ class Language { final String isoCode; Language.fromMap(Map map) - : name = map['name'], - isoCode = map['isoCode']; + : name = map['name']!, + isoCode = map['isoCode']!; } final List defaultLanguagesList = [ diff --git a/lib/utils/my_alert_dialog.dart b/lib/utils/my_alert_dialog.dart index f40c60d..adf737d 100644 --- a/lib/utils/my_alert_dialog.dart +++ b/lib/utils/my_alert_dialog.dart @@ -10,7 +10,7 @@ class MyAlertDialog extends StatelessWidget { /// null, which implies a default that depends on the values of the other /// properties. See the documentation of [titlePadding] for details. const MyAlertDialog({ - Key key, + Key? key, this.title, this.titlePadding, this.content, @@ -28,7 +28,7 @@ class MyAlertDialog extends StatelessWidget { /// of the dialog. /// /// Typically a [Text] widget. - final Widget title; + final Widget? title; /// Padding around the title. /// @@ -40,7 +40,7 @@ class MyAlertDialog extends StatelessWidget { /// provided (but see [contentPadding]). If it _is_ null, then an extra 20 /// pixels of bottom padding is added to separate the [title] from the /// [actions]. - final EdgeInsetsGeometry titlePadding; + final EdgeInsetsGeometry? titlePadding; /// The (optional) content of the dialog is displayed in the center of the /// dialog in a lighter font. @@ -48,7 +48,7 @@ class MyAlertDialog extends StatelessWidget { /// Typically, this is a [ListView] containing the contents of the dialog. /// Using a [ListView] ensures that the contents can scroll if they are too /// big to fit on the display. - final Widget content; + final Widget? content; /// Padding around the content. /// @@ -69,7 +69,7 @@ class MyAlertDialog extends StatelessWidget { /// If the [title] is not null but the [content] _is_ null, then an extra 20 /// pixels of padding is added above the [ButtonBar] to separate the [title] /// from the [actions]. - final List actions; + final List? actions; /// The semantic label of the dialog used by accessibility frameworks to /// announce screen transitions when the dialog is opened and closed. @@ -82,7 +82,7 @@ class MyAlertDialog extends StatelessWidget { /// /// * [SemanticsConfiguration.isRouteName], for a description of how this /// value is used. - final String semanticLabel; + final String? semanticLabel; /// The (optional) horizontal separator used between title, content and /// actions. @@ -97,7 +97,7 @@ class MyAlertDialog extends StatelessWidget { @override Widget build(BuildContext context) { final List children = []; - String label = semanticLabel; + String? label = semanticLabel; if (title != null) { children.add(new Padding( @@ -105,7 +105,7 @@ class MyAlertDialog extends StatelessWidget { new EdgeInsets.fromLTRB( 24.0, 24.0, 24.0, isDividerEnabled ? 20.0 : 0.0), child: new DefaultTextStyle( - style: Theme.of(context).textTheme.title, + style: Theme.of(context).textTheme.headline6!, child: new Semantics(child: title, namesRoute: true), ), )); @@ -113,12 +113,16 @@ class MyAlertDialog extends StatelessWidget { } else { switch (defaultTargetPlatform) { case TargetPlatform.iOS: + case TargetPlatform.macOS: label = semanticLabel; break; case TargetPlatform.android: case TargetPlatform.fuchsia: + case TargetPlatform.windows: + case TargetPlatform.linux: label = semanticLabel ?? - MaterialLocalizations.of(context)?.alertDialogLabel; + MaterialLocalizations.of(context).alertDialogLabel; + break; } } @@ -127,8 +131,8 @@ class MyAlertDialog extends StatelessWidget { child: new Padding( padding: contentPadding, child: new DefaultTextStyle( - style: Theme.of(context).textTheme.subhead, - child: content, + style: Theme.of(context).textTheme.subtitle1!, + child: content!, ), ), )); @@ -136,11 +140,11 @@ class MyAlertDialog extends StatelessWidget { if (actions != null) { if (isDividerEnabled) children.add(divider); - children.add(new ButtonTheme.bar( - child: new ButtonBar( - children: actions, + children.add( + new ButtonBar( + children: actions!, ), - )); + ); } Widget dialogChild = new Column( diff --git a/pubspec.yaml b/pubspec.yaml index 698a878..77899e9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,7 @@ version: 0.2.0+1 homepage: https://github.com/gomgom/flutter_language_pickers environment: - sdk: ">=2.1.0 <3.0.0" + sdk: ">=2.12.0 <3.0.0" dependencies: flutter: diff --git a/test/language_pickers_test.dart b/test/language_pickers_test.dart index 7ab863a..0da434d 100644 --- a/test/language_pickers_test.dart +++ b/test/language_pickers_test.dart @@ -1,8 +1,5 @@ import 'package:flutter_test/flutter_test.dart'; -import 'package:language_pickers/language_pickers.dart'; - void main() { - test('adds one to input values', () { - }); + test('adds one to input values', () {}); }