Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate project to nullsafety #47

Merged
merged 2 commits into from
Mar 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## [5.0.0-nullsafety.0]
* updated flutter_svg to 0.21.0-nullsafety.0
* Minimum version of dart set to 2.12.0
* Migrated to nullsafety

## [4.0.0] - Release Flags
* Support Flutter 2

Expand Down
16 changes: 8 additions & 8 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class MyApp extends StatelessWidget {
}

class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
MyHomePage({Key? key, required this.title}) : super(key: key);

final String title;

Expand All @@ -28,7 +28,7 @@ class MyHomePage extends StatefulWidget {
}

class _MyHomePageState extends State<MyHomePage> {
bool displayFlagPicker;
bool? displayFlagPicker;

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -100,7 +100,7 @@ class _MyHomePageState extends State<MyHomePage> {
FlagPicker(
width: 50,
height: 300,
preCache: displayFlagPicker,
preCache: displayFlagPicker!,
),
],
),
Expand All @@ -111,20 +111,20 @@ class _MyHomePageState extends State<MyHomePage> {
}

class FlagPicker extends StatefulWidget {
const FlagPicker({Key key, this.width, this.height, this.preCache = false})
const FlagPicker({Key? key, this.width, this.height, this.preCache = false})
: super(key: key);

final double width;
final double height;
final double? width;
final double? height;
final bool preCache;

@override
_FlagPicker createState() => _FlagPicker();
}

class _FlagPicker extends State<FlagPicker> {
FixedExtentScrollController _controller;
int _currentIndex;
late FixedExtentScrollController _controller;
late int _currentIndex;

@override
void initState() {
Expand Down
4 changes: 2 additions & 2 deletions example/lib/restart_widget.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import 'package:flutter/material.dart';

class RestartWidget extends StatefulWidget {
RestartWidget({this.child});
RestartWidget({required this.child});

final Widget child;

static void restartApp(BuildContext context) {
context.findAncestorStateOfType<_RestartWidgetState>().restartApp();
context.findAncestorStateOfType<_RestartWidgetState>()!.restartApp();
}

@override
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ description: A new Flutter project.
version: 1.0.0+1

environment:
sdk: ">=2.2.2 <3.0.0"
sdk: ">=2.12.0 <3.0.0"

dependencies:
flutter:
Expand Down
18 changes: 8 additions & 10 deletions lib/flag.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ class Flag extends StatelessWidget {
final String country;

/// If non-null, requires the child to have exactly this height.
final double height;
final double? height;

/// If non-null, requires the child to have exactly this width.
final double width;
final double? width;

/// How to inscribe the flag into the space allocated during layout.
///
Expand Down Expand Up @@ -257,16 +257,12 @@ class Flag extends StatelessWidget {
/// The [country] parameter must not be null.
Flag(
this.country, {
Key key,
Key? key,
this.height,
this.width,
this.fit = BoxFit.contain,
this.replacement = const SizedBox.shrink(),
}) : assert(
country != null,
'The Country must be provided.',
),
super(key: key);
}) : super(key: key);

@override
Widget build(BuildContext context) {
Expand All @@ -283,8 +279,10 @@ class Flag extends StatelessWidget {
: replacement;
}

static Future<void> preloadFlag(
{BuildContext context, List<String> flagList = flagsCode}) async {
static Future<void> preloadFlag({
required BuildContext context,
List<String> flagList = flagsCode,
}) async {
for (final flag in flagList) {
await PlatformSvg.preloadFlag(
context, 'packages/flag/res/flag/$flag.svg');
Expand Down
10 changes: 5 additions & 5 deletions lib/platform/interface_svg.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ class PlatformSvg extends StatelessWidget {
final String semanticLabel;

/// If non-null, requires the child to have exactly this height.
final double height;
final double? height;

/// If non-null, requires the child to have exactly this width.
final double width;
final double? width;

/// How to inscribe the flag into the space allocated during layout.
///
Expand All @@ -22,11 +22,11 @@ class PlatformSvg extends StatelessWidget {

PlatformSvg(
this.assetName, {
Key key,
this.semanticLabel,
Key? key,
this.semanticLabel = '',
this.height,
this.width,
this.fit,
this.fit = BoxFit.contain,
}) : super(key: key);

@override
Expand Down
10 changes: 5 additions & 5 deletions lib/platform/mobile_svg.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ class PlatformSvg extends Interface.PlatformSvg {
final String semanticLabel;

/// If non-null, requires the child to have exactly this height.
final double height;
final double? height;

/// If non-null, requires the child to have exactly this width.
final double width;
final double? width;

/// How to inscribe the flag into the space allocated during layout.
///
Expand All @@ -25,11 +25,11 @@ class PlatformSvg extends Interface.PlatformSvg {

PlatformSvg(
this.assetName, {
Key key,
this.semanticLabel,
Key? key,
this.semanticLabel = '',
this.height,
this.width,
this.fit,
this.fit = BoxFit.contain,
}) : super(assetName, key: key);

@override
Expand Down
10 changes: 5 additions & 5 deletions lib/platform/web_svg.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ class PlatformSvg extends Interface.PlatformSvg {
final String semanticLabel;

/// If non-null, requires the child to have exactly this height.
final double height;
final double? height;

/// If non-null, requires the child to have exactly this width.
final double width;
final double? width;

/// How to inscribe the flag into the space allocated during layout.
///
Expand All @@ -24,11 +24,11 @@ class PlatformSvg extends Interface.PlatformSvg {

PlatformSvg(
this.assetName, {
Key key,
this.semanticLabel,
Key? key,
this.semanticLabel = '',
this.height,
this.width,
this.fit,
this.fit = BoxFit.contain,
}) : super(assetName, key: key);

@override
Expand Down
2 changes: 1 addition & 1 deletion pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -178,5 +178,5 @@ packages:
source: hosted
version: "5.0.2"
sdks:
dart: ">=2.12.0-0.0 <3.0.0"
dart: ">=2.12.0 <3.0.0"
flutter: ">=1.24.0-7.0"
5 changes: 2 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
name: flag
description: A flag Flutter package. Use for showing flags. All flags came from https://www.un.org/en/member-states/index.html .
version: 4.0.0
version: 5.0.0-nullsafety.0
homepage: https://github.com/LunaGao/flag_flutter

environment:
sdk: ">=2.1.0 <3.0.0"
flutter: ">=1.17.0 <2.0.0"
sdk: ">=2.12.0 <3.0.0"

dependencies:
flutter:
Expand Down