File tree Expand file tree Collapse file tree 4 files changed +32
-7
lines changed Expand file tree Collapse file tree 4 files changed +32
-7
lines changed Original file line number Diff line number Diff line change @@ -5,8 +5,10 @@ import 'dart:async';
5
5
import 'package:flutter/foundation.dart' ;
6
6
import 'package:flutter/widgets.dart' ;
7
7
import 'package:hive/hive.dart' ;
8
- import 'package:path_provider/path_provider.dart' ;
9
- import 'package:path/path.dart' as path_helper;
8
+ import 'package:path_provider/path_provider.dart'
9
+ if (dart.library.html) 'src/stub/path_provider.dart' ;
10
+ import 'package:path/path.dart' if (dart.library.html) 'src/stub/path.dart'
11
+ as path_helper;
10
12
11
13
export 'package:hive/hive.dart' ;
12
14
Original file line number Diff line number Diff line change @@ -5,11 +5,11 @@ extension HiveX on HiveInterface {
5
5
/// Initializes Hive with the path from [getApplicationDocumentsDirectory] .
6
6
///
7
7
/// You can provide a [subDir] where the boxes should be stored.
8
- Future initFlutter ([String ? subDir]) async {
8
+ Future < void > initFlutter ([String ? subDir]) async {
9
9
WidgetsFlutterBinding .ensureInitialized ();
10
- if (! kIsWeb) {
11
- var appDir = await getApplicationDocumentsDirectory ();
12
- init (path_helper. join ( appDir.path, subDir) );
13
- }
10
+ if (kIsWeb) return ;
11
+
12
+ var appDir = await getApplicationDocumentsDirectory ( );
13
+ init (path_helper. join (appDir.path, subDir));
14
14
}
15
15
}
Original file line number Diff line number Diff line change
1
+ String join (
2
+ String part1, [
3
+ String ? part2,
4
+ String ? part3,
5
+ String ? part4,
6
+ String ? part5,
7
+ String ? part6,
8
+ String ? part7,
9
+ String ? part8,
10
+ ]) {
11
+ throw UnimplementedError (
12
+ '[Hive Error] Tried to use the `path` package from Flutter Web.' ,
13
+ );
14
+ }
Original file line number Diff line number Diff line change
1
+ abstract class Directory {
2
+ String get path;
3
+ }
4
+
5
+ Future <Directory > getApplicationDocumentsDirectory () {
6
+ throw UnimplementedError (
7
+ '[Hive Error] Tried to use the `path_provider` package from Flutter Web.' ,
8
+ );
9
+ }
You can’t perform that action at this time.
0 commit comments