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

Updates dependencies and makes null safe #2

Open
wants to merge 1 commit 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
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,7 @@ coverage/
!**/ios/**/default.mode2v3
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages

# FVM Version Cache
.fvm/
8 changes: 4 additions & 4 deletions lib/app_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ class AppState extends ChangeNotifier {
notifyListeners();
}

String _boxName;
String get boxName => _boxName;
String? _boxName;
String get boxName => _boxName ?? '';
set boxName(String boxName) {
_boxName = boxName;
notifyListeners();
}

Map<dynamic, dynamic> _entries;
Map<dynamic, dynamic> get entries => _entries;
Map<dynamic, dynamic>? _entries;
Map<dynamic, dynamic> get entries => _entries ?? <dynamic, dynamic>{};
set entries(Map<dynamic, dynamic> entries) {
_entries = entries;
notifyListeners();
Expand Down
10 changes: 6 additions & 4 deletions lib/data_explorer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class EntryWidget extends StatelessWidget {
return Card(
elevation: 0,
shape: RoundedRectangleBorder(
side: BorderSide(width: 1, color: Colors.grey[300]),
side: BorderSide(width: 1, color: Colors.grey[300]!),
borderRadius: BorderRadius.all(Radius.circular(10)),
),
clipBehavior: Clip.antiAlias,
Expand All @@ -110,9 +110,11 @@ class EntryWidget extends StatelessWidget {
),
),
),
Text(
value.toString(),
style: TextStyle(fontSize: 16),
Expanded(
child: Text(
value.toString(),
style: TextStyle(fontSize: 16),
),
),
],
),
Expand Down
15 changes: 7 additions & 8 deletions lib/file_upload.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ class FileUpload extends StatefulWidget {
}

class _FileUploadState extends State<FileUpload> {
StreamSubscription _dragOverSubscription;
StreamSubscription _dropSubscription;
StreamSubscription? _dragOverSubscription;
StreamSubscription? _dropSubscription;

@override
void initState() {
super.initState();

_dropSubscription = document.body.onDragOver.listen(_onDragOver);
_dropSubscription = document.body.onDrop.listen(_onDrop);
_dropSubscription = document.body?.onDragOver.listen(_onDragOver);
_dropSubscription = document.body?.onDrop.listen(_onDrop);
}

void _onDragOver(MouseEvent event) {
Expand All @@ -35,7 +35,7 @@ class _FileUploadState extends State<FileUpload> {
event.preventDefault();

var files = event.dataTransfer.files;
if (files.isEmpty) return;
if (files == null || files.isEmpty) return;

var file = files.first;
var reader = FileReader();
Expand All @@ -44,12 +44,12 @@ class _FileUploadState extends State<FileUpload> {
});
reader.readAsArrayBuffer(file);

var appState = Provider.of<AppState>(context);
var appState = Provider.of<AppState>(context, listen: false);
appState.status = UploadStatus.processing;
}

void _process(String name, Uint8List bytes) {
var appState = Provider.of<AppState>(context);
var appState = Provider.of<AppState>(context, listen: false);
scheduleMicrotask(() async {
try {
var box = await Hive.openBox('box', bytes: bytes);
Expand Down Expand Up @@ -84,7 +84,6 @@ class _FileUploadState extends State<FileUpload> {
case UploadStatus.success:
return DataExplorer();
}
return Container();
}

@override
Expand Down
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:studio/object_adapter.dart';

void main() {
for (var i = 0; i < 224; i++) {
Hive.registerAdapter(ObjectAdapter(), i);
Hive.registerAdapter(ObjectAdapter(i));
}
runApp(MyApp());
}
Expand Down
7 changes: 7 additions & 0 deletions lib/object_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ import 'dart:typed_data';
import 'package:hive/hive.dart';

class ObjectAdapter extends TypeAdapter<Object> {
final int _typeId;

ObjectAdapter(this._typeId);

@override
int get typeId => _typeId;

@override
Object read(BinaryReader reader) {
var bytes = reader.peekBytes(reader.availableBytes);
Expand Down
2 changes: 1 addition & 1 deletion lib/path_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class PathView extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Consumer<AppState>(
builder: (BuildContext context, AppState app, Widget child) {
builder: (BuildContext context, AppState app, Widget? child) {
return Row(
children: <Widget>[
_buildPathElement(app.boxName, () {
Expand Down
6 changes: 3 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ description: A new Flutter project.
version: 1.0.0+1

environment:
sdk: ">=2.6.0 <3.0.0"
sdk: '>=3.0.3 <4.0.0'

dependencies:
flutter:
sdk: flutter

hive: 1.2.0
hive: ^2.2.3
provider: any

dev_dependencies:
pedantic: 1.9.0
pedantic: ^1.11.1

flutter:
uses-material-design: true
Expand Down