|
| 1 | +Add this dependency-->> |
| 2 | +device_preview: ^0.7.4 |
| 3 | + |
| 4 | +import 'dart:io'; |
| 5 | +import 'package:device_preview/device_preview.dart'; |
| 6 | +import 'package:device_preview/plugins.dart'; |
| 7 | +import 'package:flutter/cupertino.dart'; |
| 8 | +import 'package:flutter/foundation.dart'; |
| 9 | +import 'package:flutter/material.dart'; |
| 10 | +import 'package:path_provider/path_provider.dart'; |
| 11 | +import 'package:path/path.dart' as path; |
| 12 | + |
| 13 | +import 'basic.dart'; |
| 14 | + |
| 15 | +void main() { |
| 16 | + debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia; |
| 17 | + |
| 18 | + WidgetsFlutterBinding.ensureInitialized(); |
| 19 | + |
| 20 | + _createFakeData(); |
| 21 | + |
| 22 | + runApp(Row( |
| 23 | + textDirection: TextDirection.ltr, |
| 24 | + crossAxisAlignment: CrossAxisAlignment.stretch, |
| 25 | + children: [ |
| 26 | + /*Expanded( |
| 27 | + child: Container(color: Colors.red), |
| 28 | + ),*/ |
| 29 | + Expanded( |
| 30 | + child: DevicePreview( |
| 31 | + enabled: true, |
| 32 | + plugins: [ |
| 33 | + const ScreenshotPlugin(), |
| 34 | + const FileExplorerPlugin(), |
| 35 | + const SharedPreferencesExplorerPlugin(), |
| 36 | + ], |
| 37 | + builder: (context) => BasicApp(), |
| 38 | + ), |
| 39 | + ), |
| 40 | + ], |
| 41 | + )); |
| 42 | +} |
| 43 | + |
| 44 | +Future<void> _createFakeData() async { |
| 45 | + final directory = (await getApplicationDocumentsDirectory()).path; |
| 46 | + |
| 47 | + final file1 = File(path.join(directory, 'example.json')); |
| 48 | + await file1.writeAsString('{ "example": true}'); |
| 49 | + |
| 50 | + final directoryWithFile = Directory(path.join(directory, 'subdir')); |
| 51 | + await directoryWithFile.create(); |
| 52 | + |
| 53 | + final emptyDirectory = Directory(path.join(directory, 'emptyDir')); |
| 54 | + await emptyDirectory.create(); |
| 55 | + |
| 56 | + final file2 = File(path.join(directoryWithFile.path, 'example2.json')); |
| 57 | + await file2.writeAsString('{ "example2": true}'); |
| 58 | + |
| 59 | + final file3 = File(path.join(directoryWithFile.path, 'example2.bin')); |
| 60 | + await file3.writeAsString('kjh8bhb'); |
| 61 | +} |
0 commit comments