王亚玲 2 years ago
parent 7211d15be2
commit c11c631229

@ -0,0 +1,27 @@
import 'package:hive/hive.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:equatable/equatable.dart';
import 'content_list_model.dart';
part 'ContentHive.g.dart';
@JsonSerializable()
@HiveType(typeId:2)
class ContentHive extends Equatable{
@HiveField(0)
final int id;
@HiveField(1)
final String content;
@HiveField(2)
final List<ContentListModel> list;
factory ContentHive.fromJson(Map<String, dynamic> json) =>_$ContentHiveFromJson(json);
const ContentHive({
required this.id,
required this.content,
required this.list,
});
@override
List<Object?> get props => [id,content,list];
}

@ -0,0 +1,59 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'ContentHive.dart';
// **************************************************************************
// TypeAdapterGenerator
// **************************************************************************
class ContentHiveAdapter extends TypeAdapter<ContentHive> {
@override
final int typeId = 0;
@override
ContentHive read(BinaryReader reader) {
final numOfFields = reader.readByte();
final fields = <int, dynamic>{
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
};
return ContentHive(
id: fields[0] as int,
content: fields[1] as String,
list: (fields[3] as List).cast<ContentListModel>(),
);
}
@override
void write(BinaryWriter writer, ContentHive obj) {
writer
..writeByte(3)
..writeByte(0)
..write(obj.id)
..writeByte(1)
..write(obj.content)
..writeByte(3)
..write(obj.list);
}
@override
int get hashCode => typeId.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is ContentHiveAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
ContentHive _$ContentHiveFromJson(Map<String, dynamic> json) => ContentHive(
id: json['id'] as int,
content: json['content'] as String,
list: (json['list'] as List<dynamic>)
.map((e) => ContentListModel.fromJson(e as Map<String, dynamic>))
.toList(),
);

@ -0,0 +1,19 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:equatable/equatable.dart';
part 'content_list_model.g.dart';
@JsonSerializable()
class ContentListModel extends Equatable{
final int index;
final String content;
factory ContentListModel.fromJson(Map<String, dynamic> json) =>_$ContentListModelFromJson(json);
const ContentListModel({
required this.index,
required this.content,
});
@override
List<Object?> get props => [index,content];
}

@ -0,0 +1,13 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'content_list_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
ContentListModel _$ContentListModelFromJson(Map<String, dynamic> json) =>
ContentListModel(
index: json['index'] as int,
content: json['content'] as String,
);

@ -0,0 +1,14 @@
import 'package:flutter/material.dart';
import 'package:hive/hive.dart';
import '../model/hive/ContentHive.dart';
class ContentListModel extends ChangeNotifier{
late Box _regionBox;
List<ContentHive> _regions=[];
List<ContentHive> get regions=>_regions;
Future init() async{}
// _regionBox = await Hive.openBox("ContentListBox");
// var
}

@ -1,9 +1,10 @@
import 'dart:io';
import 'package:call_log/call_log.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_sms/flutter_sms.dart';
import 'package:get_phone_number/get_phone_number.dart';
import 'package:hive/hive.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:project_telephony/base/base_style.dart';
import 'package:project_telephony/ui/home/content_details_page.dart';
@ -72,11 +73,7 @@ class _ContentPageState extends State<ContentPage> {
},
));
} else {
bool? permissionsGranted = await telephony.requestPhonePermissions;
final Iterable<CallLogEntry> result = await CallLog.query();
phoneNum = result.first.number!;
print(phoneNum);
// bool? permissionsGranted = await telephony.requestPhonePermissions;
// print(permissionsGranted);
// if(permissionsGranted!){
// print(content);
@ -95,10 +92,10 @@ class _ContentPageState extends State<ContentPage> {
// message: content,
// isMultipart: true
// );
List<String> recipents=[
phoneNum
];
_sendSMS(content,recipents);
// List<String> recipents=[
// phoneNum
// ];
// _sendSMS(content,recipents);
// String phoneNumber = await GetPhoneNumber().get();
// print('getPhoneNumber result: $phoneNumber');
}

Loading…
Cancel
Save