Skip to content
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
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
11 changes: 1 addition & 10 deletions android/src/main/java/flutter/moum/sim_info/SimInfoPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 20 additions & 7 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:label="sim_info_example"
android:icon="@mipmap/ic_launcher">
<activity
Expand All @@ -19,17 +18,31 @@
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- This keeps the window background of the activity showing
until Flutter renders its first frame. It can be removed if
there is no splash screen (such as the default splash screen
defined in @style/LaunchTheme). -->
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<meta-data
android:name="flutterEmbedding"
android:value="2" />

</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
import io.flutter.embedding.android.FlutterActivity;

public class MainActivity extends FlutterActivity {

}
12 changes: 11 additions & 1 deletion example/android/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
<style name="LaunchTheme" parent="@android:style/Theme.Light.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.Light.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>
18 changes: 9 additions & 9 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ class MyApp extends StatefulWidget {
}

class _MyAppState extends State<MyApp> {
String _allowsVOIP;
String _carrierName;
String _isoCountryCode;
String _mobileCountryCode;
String _mobileNetworkCode;
String? _allowsVOIP;
String? _carrierName;
String? _isoCountryCode;
String? _mobileCountryCode;
String? _mobileNetworkCode;

@override
void initState() {
Expand All @@ -24,10 +24,10 @@ class _MyAppState extends State<MyApp> {

Future<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? carrierName = await SimInfo.getCarrierName;
String? isoCountryCode = await SimInfo.getIsoCountryCode;
String? mobileCountryCode = await SimInfo.getMobileCountryCode;
String? mobileNetworkCode = await SimInfo.getMobileNetworkCode;

setState(() {
_allowsVOIP = allowsVOIP;
Expand Down
12 changes: 6 additions & 6 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@ 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:
sdk: flutter

# 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

Expand Down
2 changes: 1 addition & 1 deletion example/test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand Down
10 changes: 5 additions & 5 deletions lib/sim_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ class SimInfo {
const MethodChannel('flutter.moum.sim_info');

static Future<String> get getAllowsVOIP async {
bool value = await _channel.invokeMethod('allowsVOIP');
bool? value = await _channel.invokeMethod('allowsVOIP');
return value.toString();
}

static Future<String> get getCarrierName async {
static Future<String?> get getCarrierName async {
return await _channel.invokeMethod('carrierName');
}

static Future<String> get getIsoCountryCode async {
static Future<String?> get getIsoCountryCode async {
return await _channel.invokeMethod('isoCountryCode');
}

static Future<String> get getMobileCountryCode async {
static Future<String?> get getMobileCountryCode async {
return await _channel.invokeMethod('mobileCountryCode');
}

static Future<String> get getMobileNetworkCode async {
static Future<String?> get getMobileNetworkCode async {
return await _channel.invokeMethod('mobileNetworkCode');
}

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down