Skip to content

Commit

Permalink
Merge pull request #83 from tappeddev/stable
Browse files Browse the repository at this point in the history
Upgrade svg package and remove caching
  • Loading branch information
LunaGao committed Jun 9, 2023
2 parents 988b830 + 8300d43 commit 4687628
Show file tree
Hide file tree
Showing 9 changed files with 135 additions and 104 deletions.
2 changes: 1 addition & 1 deletion example/ios/Flutter/AppFrameworkInfo.plist
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>8.0</string>
<string>11.0</string>
</dict>
</plist>
12 changes: 7 additions & 5 deletions example/ios/Runner.xcodeproj/project.pbxproj
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -140,7 +140,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1020;
LastUpgradeCheck = 1300;
ORGANIZATIONNAME = "The Chromium Authors";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down Expand Up @@ -184,6 +184,7 @@
/* Begin PBXShellScriptBuildPhase section */
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand All @@ -198,6 +199,7 @@
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand Down Expand Up @@ -286,7 +288,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down Expand Up @@ -365,7 +367,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -414,7 +416,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
LastUpgradeVersion = "1300"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
4 changes: 4 additions & 0 deletions example/ios/Runner/Info.plist
Expand Up @@ -41,5 +41,9 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
</dict>
</plist>
17 changes: 5 additions & 12 deletions example/lib/main.dart
Expand Up @@ -110,7 +110,6 @@ class _MyHomePageState extends State<MyHomePage> {
FlagPicker(
width: 50,
height: 300,
preCache: displayFlagPicker!,
),
],
),
Expand All @@ -121,12 +120,14 @@ class _MyHomePageState extends State<MyHomePage> {
}

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

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

@override
_FlagPicker createState() => _FlagPicker();
Expand All @@ -145,14 +146,6 @@ class _FlagPicker extends State<FlagPicker> {
);
}

@override
void didChangeDependencies() {
super.didChangeDependencies();
if (widget.preCache) {
Flag.preloadFlag(context: context);
}
}

@override
void dispose() {
_controller.dispose();
Expand Down
14 changes: 0 additions & 14 deletions lib/flag_widget.dart
Expand Up @@ -133,18 +133,4 @@ class Flag extends StatelessWidget {
return returnWidget;
}
}

static Future<void> preloadFlag({
required BuildContext context,
List<String> flagList = flagsCode,
}) async {
for (final flag in flagList) {
await precachePicture(
ExactAssetPicture(
SvgPicture.svgStringDecoderBuilder,
'packages/flag/res/4x3/$flag.svg',
),
context);
}
}
}
20 changes: 9 additions & 11 deletions lib/flags_widget.dart
Expand Up @@ -15,7 +15,7 @@ class Flags extends StatelessWidget {
/// The flag to display. Enum value for `FlagsCode`.
///
/// This value listed in https://github.com/LunaGao/flag_flutter/blob/master/un_members.txt.
final List<FlagsCode> countiyCodes;
final List<FlagsCode> countryCodes;

/// Requires the child to have exactly this height.
///
Expand Down Expand Up @@ -61,15 +61,15 @@ class Flags extends StatelessWidget {
///
/// The [country] parameter must not be null.
const Flags.fromCode(
this.countiyCodes, {
this.countryCodes, {
Key? key,
this.height = 300,
this.width = 400,
this.replacement = const SizedBox.shrink(),
this.flagSize = FlagSize.size_4x3,
this.borderRadius,
}) : assert(
countiyCodes.length == 2,
countryCodes.length == 2,
'countiyCodes count must be 2.',
),
this.counties = const [],
Expand All @@ -92,16 +92,16 @@ class Flags extends StatelessWidget {
counties.length == 2,
'counties count must be 2.',
),
this.countiyCodes = const [],
this.countryCodes = const [],
super(key: key);

@override
Widget build(BuildContext context) {
List<String> countryNames =
this.counties.map((e) => e.toLowerCase()).toList();
if (this.countiyCodes.isNotEmpty) {
if (this.countryCodes.isNotEmpty) {
countryNames = this
.countiyCodes
.countryCodes
.map((e) => EnumToString.convertToString(e).toLowerCase())
.toList();
}
Expand Down Expand Up @@ -149,17 +149,15 @@ class Flags extends StatelessWidget {
}
}

Widget returnWidget = Stack(
children: flagWidgets,
);
Widget buildChild() => Stack(children: flagWidgets);

if (borderRadius != null) {
return ClipRRect(
borderRadius: BorderRadius.circular(borderRadius!),
child: returnWidget,
child: buildChild(),
);
} else {
return returnWidget;
return buildChild();
}
}
}

0 comments on commit 4687628

Please sign in to comment.