diff --git a/README.md b/README.md
index 6df6702..2471ab3 100644
--- a/README.md
+++ b/README.md
@@ -28,11 +28,11 @@ import 'package:sim_info/sim_info.dart';
Use below to get SIM data:
```dart
- String _allowsVOIP;
- String _carrierName;
- String _isoCountryCode;
- String _mobileCountryCode;
- String _mobileNetworkCode;
+ String? _allowsVOIP;
+ String? _carrierName;
+ String? _isoCountryCode;
+ String? _mobileCountryCode;
+ String? _mobileNetworkCode;
@override
void initState() {
@@ -41,11 +41,11 @@ Use below to get SIM data:
}
void getSimInfo() async {
- String allowsVOIP = await SimInfo.getAllowsVOIP;
- String carrierName = await SimInfo.getCarrierName;
- String isoCountryCode = await SimInfo.getIsoCountryCode;
- String mobileCountryCode = await SimInfo.getMobileCountryCode;
- String mobileNetworkCode = await SimInfo.getMobileNetworkCode;
+ String? allowsVOIP = await SimInfo.getAllowsVOIP;
+ String? carrierName = await SimInfo.getCarrierName;
+ String? isoCountryCode = await SimInfo.getIsoCountryCode;
+ String? mobileCountryCode = await SimInfo.getMobileCountryCode;
+ String? mobileNetworkCode = await SimInfo.getMobileNetworkCode;
}
```
[Full list of available SIM data](https://github.com/flutter-moum/flutter_sim_info/wiki).
diff --git a/android/src/main/java/flutter/moum/sim_info/MethodHandlerImpl.java b/android/src/main/java/flutter/moum/sim_info/MethodHandlerImpl.java
index 2e1f820..cc95678 100644
--- a/android/src/main/java/flutter/moum/sim_info/MethodHandlerImpl.java
+++ b/android/src/main/java/flutter/moum/sim_info/MethodHandlerImpl.java
@@ -14,7 +14,8 @@ class MethodHandlerImpl implements MethodChannel.MethodCallHandler {
Context context;
private final TelephonyManager mTelephonyManager;
- public MethodHandlerImpl() {
+ public MethodHandlerImpl(Context context) {
+ this.context = context;
mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
}
diff --git a/android/src/main/java/flutter/moum/sim_info/SimInfoPlugin.java b/android/src/main/java/flutter/moum/sim_info/SimInfoPlugin.java
index 08131b2..16b111a 100644
--- a/android/src/main/java/flutter/moum/sim_info/SimInfoPlugin.java
+++ b/android/src/main/java/flutter/moum/sim_info/SimInfoPlugin.java
@@ -6,23 +6,14 @@
import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugin.common.MethodChannel;
-import io.flutter.plugin.common.PluginRegistry.Registrar;
/** SimInfoPlugin */
public class SimInfoPlugin implements FlutterPlugin {
private MethodChannel channel;
-
- /** Plugin registration. */
- public static void registerWith(Registrar registrar) {
- SimInfoPlugin plugin = new SimInfoPlugin();
- plugin.setMethodChannel(registrar.context(), registrar.messenger());
- }
-
private void setMethodChannel(Context context, BinaryMessenger messenger) {
channel = new MethodChannel(messenger, "flutter.moum.sim_info");
- channel.setMethodCallHandler(new MethodHandlerImpl());
-
+ channel.setMethodCallHandler(new MethodHandlerImpl(context));
}
@Override
diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml
index f5aa146..e3dd5ae 100644
--- a/example/android/app/src/main/AndroidManifest.xml
+++ b/example/android/app/src/main/AndroidManifest.xml
@@ -9,7 +9,6 @@
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
-
+
+ android:name="io.flutter.embedding.android.NormalTheme"
+ android:resource="@style/NormalTheme"
+ />
+
+
+
+
diff --git a/example/android/app/src/main/java/flutter/moum/sim_info_example/MainActivity.java b/example/android/app/src/main/java/flutter/moum/sim_info_example/MainActivity.java
index 19a8873..30b30eb 100644
--- a/example/android/app/src/main/java/flutter/moum/sim_info_example/MainActivity.java
+++ b/example/android/app/src/main/java/flutter/moum/sim_info_example/MainActivity.java
@@ -3,5 +3,4 @@
import io.flutter.embedding.android.FlutterActivity;
public class MainActivity extends FlutterActivity {
-
}
diff --git a/example/android/app/src/main/res/values/styles.xml b/example/android/app/src/main/res/values/styles.xml
index 00fa441..d460d1e 100644
--- a/example/android/app/src/main/res/values/styles.xml
+++ b/example/android/app/src/main/res/values/styles.xml
@@ -1,8 +1,18 @@
-
+
+
diff --git a/example/lib/main.dart b/example/lib/main.dart
index 42335cf..0ecccfd 100644
--- a/example/lib/main.dart
+++ b/example/lib/main.dart
@@ -10,11 +10,11 @@ class MyApp extends StatefulWidget {
}
class _MyAppState extends State {
- String _allowsVOIP;
- String _carrierName;
- String _isoCountryCode;
- String _mobileCountryCode;
- String _mobileNetworkCode;
+ String? _allowsVOIP;
+ String? _carrierName;
+ String? _isoCountryCode;
+ String? _mobileCountryCode;
+ String? _mobileNetworkCode;
@override
void initState() {
@@ -24,10 +24,10 @@ class _MyAppState extends State {
Future getSimInfo() async {
String allowsVOIP = await SimInfo.getAllowsVOIP;
- String carrierName = await SimInfo.getCarrierName;
- String isoCountryCode = await SimInfo.getIsoCountryCode;
- String mobileCountryCode = await SimInfo.getMobileCountryCode;
- String mobileNetworkCode = await SimInfo.getMobileNetworkCode;
+ String? carrierName = await SimInfo.getCarrierName;
+ String? isoCountryCode = await SimInfo.getIsoCountryCode;
+ String? mobileCountryCode = await SimInfo.getMobileCountryCode;
+ String? mobileNetworkCode = await SimInfo.getMobileNetworkCode;
setState(() {
_allowsVOIP = allowsVOIP;
diff --git a/example/pubspec.yaml b/example/pubspec.yaml
index 5b34acb..e4dbd3d 100644
--- a/example/pubspec.yaml
+++ b/example/pubspec.yaml
@@ -3,7 +3,7 @@ description: Demonstrates how to use the sim_info plugin.
publish_to: 'none'
environment:
- sdk: ">=2.1.0 <3.0.0"
+ sdk: '>=2.12.0 <3.0.0'
dependencies:
flutter:
@@ -11,16 +11,16 @@ dependencies:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
- cupertino_icons: ^0.1.2
- permission_handler: ^3.2.0
+ cupertino_icons: ^1.0.3
+ permission_handler: ^8.1.6
+
+ sim_info:
+ path: ../
dev_dependencies:
flutter_test:
sdk: flutter
- sim_info:
- path: ../
-
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart
index 6a8c71d..f48d9f9 100644
--- a/example/test/widget_test.dart
+++ b/example/test/widget_test.dart
@@ -19,7 +19,7 @@ void main() {
expect(
find.byWidgetPredicate(
(Widget widget) => widget is Text &&
- widget.data.startsWith('Running on:'),
+ widget.data!.startsWith('Running on:'),
),
findsOneWidget,
);
diff --git a/lib/sim_info.dart b/lib/sim_info.dart
index e44b0dc..ae8bce2 100644
--- a/lib/sim_info.dart
+++ b/lib/sim_info.dart
@@ -8,23 +8,23 @@ class SimInfo {
const MethodChannel('flutter.moum.sim_info');
static Future get getAllowsVOIP async {
- bool value = await _channel.invokeMethod('allowsVOIP');
+ bool? value = await _channel.invokeMethod('allowsVOIP');
return value.toString();
}
- static Future get getCarrierName async {
+ static Future get getCarrierName async {
return await _channel.invokeMethod('carrierName');
}
- static Future get getIsoCountryCode async {
+ static Future get getIsoCountryCode async {
return await _channel.invokeMethod('isoCountryCode');
}
- static Future get getMobileCountryCode async {
+ static Future get getMobileCountryCode async {
return await _channel.invokeMethod('mobileCountryCode');
}
- static Future get getMobileNetworkCode async {
+ static Future get getMobileNetworkCode async {
return await _channel.invokeMethod('mobileNetworkCode');
}
diff --git a/pubspec.yaml b/pubspec.yaml
index 6573925..799a503 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -6,7 +6,7 @@ homepage: https://github.com/flutter-moum/flutter_sim_info
environment:
- sdk: ">=2.1.0 <3.0.0"
+ sdk: '>=2.12.0 <3.0.0'
flutter: ">=1.12.0 <2.0.0"
dependencies: