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

Null safety migration #167

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ group 'com.humazed.google_map_location_picker'
version '1.0-SNAPSHOT'

buildscript {
ext.kotlin_version = '1.3.31'
ext.kotlin_version = '1.3.40'
repositories {
google()
jcenter()
Expand Down
2 changes: 1 addition & 1 deletion example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.humazed.google_map_location_picker_example"
minSdkVersion 16
minSdkVersion 20
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Expand Down
8 changes: 4 additions & 4 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@
</intent-filter>
</activity>

<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<!-- <meta-data-->
<!-- android:name="com.google.android.gms.version"-->
<!-- android:value="1" />-->
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/GOOGLE_MAPS_API_KEY" />
android:value="API_KEY" />
</application>
</manifest>
18 changes: 18 additions & 0 deletions example/android/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Theme applied to the Android Window while the process is starting -->
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
Flutter draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">@android:color/white</item>
</style>
</resources>
2 changes: 1 addition & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
classpath 'com.android.tools.build:gradle:4.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
13 changes: 13 additions & 0 deletions example/ios/Flutter/flutter_export_environment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh
# This is a generated file; do not edit or check into version control.
export "FLUTTER_ROOT=/Users/blb/Development/flutter"
export "FLUTTER_APPLICATION_PATH=/Users/blb/Development/google_map_location_picker/example"
export "COCOAPODS_PARALLEL_CODE_SIGN=true"
export "FLUTTER_TARGET=lib/main.dart"
export "FLUTTER_BUILD_DIR=build"
export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1.0.0"
export "DART_OBFUSCATION=false"
export "TRACK_WIDGET_CREATION=false"
export "TREE_SHAKE_ICONS=false"
export "PACKAGE_CONFIG=.packages"
32 changes: 16 additions & 16 deletions example/lib/generated/i18n.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import 'package:flutter/material.dart';
class S implements WidgetsLocalizations {
const S();

static S current;
static S? current;

static const GeneratedLocalizationsDelegate delegate =
GeneratedLocalizationsDelegate();

static S of(BuildContext context) => Localizations.of<S>(context, S);
static S? of(BuildContext context) => Localizations.of<S>(context, S);

@override
TextDirection get textDirection => TextDirection.ltr;
Expand All @@ -33,7 +33,7 @@ class $en extends S {
const $en();
}

class GeneratedLocalizationsDelegate extends LocalizationsDelegate<S> {
class GeneratedLocalizationsDelegate extends LocalizationsDelegate<S?> {
const GeneratedLocalizationsDelegate();

List<Locale> get supportedLocales {
Expand All @@ -44,8 +44,8 @@ class GeneratedLocalizationsDelegate extends LocalizationsDelegate<S> {
}

LocaleListResolutionCallback listResolution(
{Locale fallback, bool withCountry = true}) {
return (List<Locale> locales, Iterable<Locale> supported) {
{Locale? fallback, bool withCountry = true}) {
return (List<Locale>? locales, Iterable<Locale> supported) {
if (locales == null || locales.isEmpty) {
return fallback ?? supported.first;
} else {
Expand All @@ -55,29 +55,29 @@ class GeneratedLocalizationsDelegate extends LocalizationsDelegate<S> {
}

LocaleResolutionCallback resolution(
{Locale fallback, bool withCountry = true}) {
return (Locale locale, Iterable<Locale> supported) {
{Locale? fallback, bool withCountry = true}) {
return (Locale? locale, Iterable<Locale> supported) {
return _resolve(locale, fallback, supported, withCountry);
};
}

@override
Future<S> load(Locale locale) {
final String lang = getLang(locale);
Future<S?> load(Locale locale) {
final String? lang = getLang(locale);
if (lang != null) {
switch (lang) {
case "ar":
S.current = const $ar();
return SynchronousFuture<S>(S.current);
return SynchronousFuture<S?>(S.current);
case "en":
S.current = const $en();
return SynchronousFuture<S>(S.current);
return SynchronousFuture<S?>(S.current);
default:
// NO-OP.
}
}
S.current = const S();
return SynchronousFuture<S>(S.current);
return SynchronousFuture<S?>(S.current);
}

@override
Expand All @@ -89,7 +89,7 @@ class GeneratedLocalizationsDelegate extends LocalizationsDelegate<S> {
///
/// Internal method to resolve a locale from a list of locales.
///
Locale _resolve(Locale locale, Locale fallback, Iterable<Locale> supported,
Locale _resolve(Locale? locale, Locale? fallback, Iterable<Locale> supported,
bool withCountry) {
if (locale == null || !_isSupported(locale, withCountry)) {
return fallback ?? supported.first;
Expand Down Expand Up @@ -125,7 +125,7 @@ class GeneratedLocalizationsDelegate extends LocalizationsDelegate<S> {
// If no country requirement is requested, check if this locale has no country.
if (true != withCountry &&
(supportedLocale.countryCode == null ||
supportedLocale.countryCode.isEmpty)) {
supportedLocale.countryCode!.isEmpty)) {
return true;
}
}
Expand All @@ -134,8 +134,8 @@ class GeneratedLocalizationsDelegate extends LocalizationsDelegate<S> {
}
}

String getLang(Locale l) => l == null
String? getLang(Locale l) => l == null
? null
: l.countryCode != null && l.countryCode.isEmpty
: l.countryCode != null && l.countryCode!.isEmpty
? l.languageCode
: l.toString();
7 changes: 3 additions & 4 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:google_map_location_picker/generated/l10n.dart'
as location_picker;
import 'package:google_map_location_picker/google_map_location_picker.dart';
import 'package:google_map_location_picker_example/keys.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';

import 'generated/i18n.dart';
Expand All @@ -16,7 +15,7 @@ class MyApp extends StatefulWidget {
}

class _MyAppState extends State<MyApp> {
LocationResult _pickedLocation;
LocationResult? _pickedLocation;

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -50,9 +49,9 @@ class _MyAppState extends State<MyApp> {
children: <Widget>[
RaisedButton(
onPressed: () async {
LocationResult result = await showLocationPicker(
LocationResult? result = await showLocationPicker(
context,
apiKey,
"API_KEY",
initialCenter: LatLng(31.1975844, 29.9598339),
// automaticallyAnimateToCurrentLocation: true,
// mapStylePath: 'assets/mapStyle.json',
Expand Down
Loading