diff --git a/lib/Editor.dart b/lib/Editor.dart index 79c0942..c0da51b 100644 --- a/lib/Editor.dart +++ b/lib/Editor.dart @@ -1,12 +1,9 @@ -import 'dart:convert'; -import 'dart:typed_data'; import 'package:file_picker/file_picker.dart'; import 'package:flutter/material.dart'; import 'package:flutter_treeview/flutter_treeview.dart'; import 'package:libac_dart/nbt/NbtIo.dart'; import 'package:libac_dart/nbt/SnbtIo.dart'; -import 'package:libac_dart/nbt/Stream.dart'; import 'package:libac_dart/nbt/Tag.dart'; import 'package:libac_dart/nbt/impl/CompoundTag.dart'; import 'package:nbteditor/Constants.dart'; @@ -73,7 +70,7 @@ class EditorState extends State { children: [ Text("Named Binary Tag Editor"), Text("Created by Tara Piccari"), - Text("Version: ${VERSION}") + Text("Version: $VERSION") ], )), ListTile( @@ -127,9 +124,9 @@ class EditorState extends State { }, ), ListTile( - title: Text("S A V E N B T"), - subtitle: Text("Save to NBT"), - leading: Image( + title: const Text("S A V E N B T"), + subtitle: const Text("Save to NBT"), + leading: const Image( image: AssetImage("Icons/PNG/AppLogo.png"), ), onTap: () async { @@ -146,18 +143,18 @@ class EditorState extends State { context: context, builder: (builder) { return AlertDialog( - title: Text("Compress the data?"), + title: const Text("Compress the data?"), actions: [ ElevatedButton( onPressed: () { Navigator.pop(context, true); }, - child: Text("YES")), + child: const Text("YES")), ElevatedButton( onPressed: () { Navigator.pop(context); }, - child: Text("No")) + child: const Text("No")) ], ); }); @@ -165,16 +162,17 @@ class EditorState extends State { if (result == null) { // Save uncompressed NbtIo.write( - filePath!, controller.children[0].data as CompoundTag); - } else + filePath, controller.children[0].data as CompoundTag); + } else { NbtIo.writeCompressed( - filePath!, controller.children[0].data as CompoundTag); + filePath, controller.children[0].data as CompoundTag); + } }, ), ListTile( - title: Text("S A V E S N B T"), - subtitle: Text("Save to SNBT"), - leading: Image( + title: const Text("S A V E S N B T"), + subtitle: const Text("Save to SNBT"), + leading: const Image( image: AssetImage("Icons/PNG/String.png"), ), onTap: () async { @@ -188,7 +186,7 @@ class EditorState extends State { print(filePath); SnbtIo.writeToFile( - filePath!, controller.children[0].data as CompoundTag); + filePath, controller.children[0].data as CompoundTag); }, ) ]), @@ -199,7 +197,7 @@ class EditorState extends State { return TagExt.render(node.data as Tag, context, didChangeState); } else { return ListTile( - title: Text("${node.label}"), + title: Text(node.label), ); } }, diff --git a/lib/main.dart b/lib/main.dart index 0709dd6..ff68eef 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:nbteditor/Editor.dart'; import 'package:nbteditor/pages/AddPage.dart'; -import 'package:nbteditor/pages/EditValue.dart'; import 'package:nbteditor/pages/SNBTEditor.dart'; void main() { diff --git a/lib/pages/AddPage.dart b/lib/pages/AddPage.dart index e7b8588..971214f 100644 --- a/lib/pages/AddPage.dart +++ b/lib/pages/AddPage.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:flutter/widgets.dart'; import 'package:libac_dart/nbt/Tag.dart'; import 'package:libac_dart/nbt/impl/ByteArrayTag.dart'; import 'package:libac_dart/nbt/impl/IntArrayTag.dart'; @@ -63,9 +62,9 @@ class AddState extends State { if (!(isArray || isList)) { var reply = await showDialog( context: context, - routeSettings: RouteSettings(arguments: ""), + routeSettings: const RouteSettings(arguments: ""), builder: (builder) { - return RenamePrompt(); + return const RenamePrompt(); }); newTagName = reply as String; } @@ -84,7 +83,7 @@ class AddState extends State { context: context, routeSettings: RouteSettings(arguments: nTag), builder: (builder) { - return EditValuePrompt(); + return const EditValuePrompt(); }); val = reply; } @@ -135,7 +134,7 @@ class AddState extends State { if (isList || isArray && !canAddAnyType && singleShot) { singleShot = false; - Future.delayed(Duration(seconds: 2), () { + Future.delayed(const Duration(seconds: 2), () { processTagType(allowedTagTypes[0]); }); } @@ -146,7 +145,7 @@ class AddState extends State { backgroundColor: Constants.TITLEBAR_COLOR, ), body: Padding( - padding: EdgeInsets.all(8), + padding: const EdgeInsets.all(8), child: ListView.builder( itemBuilder: (builder, index) { return ListTile( diff --git a/lib/pages/EditValue.dart b/lib/pages/EditValue.dart index 4260256..1db4b39 100644 --- a/lib/pages/EditValue.dart +++ b/lib/pages/EditValue.dart @@ -3,6 +3,8 @@ import 'package:libac_dart/nbt/Tag.dart'; import 'package:libac_dart/nbt/impl/StringTag.dart'; class EditValuePrompt extends StatefulWidget { + const EditValuePrompt({super.key}); + @override State createState() { return EditValueState(); @@ -22,7 +24,7 @@ class EditValueState extends State { if (args == null) return; if (args is Tag) { - Tag tag = args as Tag; + Tag tag = args; setState(() { TagValueType = tag.getTagType(); MainTag = tag; @@ -35,7 +37,7 @@ class EditValueState extends State { @override Widget build(BuildContext context) { return AlertDialog( - icon: Icon(Icons.edit_document), + icon: const Icon(Icons.edit_document), title: Text("Edit Value - ${MainTag.getKey()}"), actions: [ ElevatedButton( @@ -64,16 +66,16 @@ class EditValueState extends State { } Navigator.pop(context, val); }, - child: Text("Submit")), + child: const Text("Submit")), ElevatedButton( onPressed: () { Navigator.pop(context); }, - child: Text("Cancel")) + child: const Text("Cancel")) ], content: TextField( controller: TEC, - decoration: InputDecoration(border: OutlineInputBorder()), + decoration: const InputDecoration(border: OutlineInputBorder()), )); } } diff --git a/lib/tags/Tag.dart b/lib/tags/Tag.dart index 8983e29..ca2e7df 100644 --- a/lib/tags/Tag.dart +++ b/lib/tags/Tag.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_treeview/flutter_treeview.dart'; import 'package:libac_dart/nbt/Tag.dart'; @@ -193,7 +192,7 @@ class TagExt { allowedTagTypes: allowedTypes, didChangeState: didChangeState)); }, - icon: Icon(Icons.add)), + icon: const Icon(Icons.add)), if (isNamed) IconButton( onPressed: () async { @@ -211,14 +210,14 @@ class TagExt { state.update(); } }, - icon: Icon(Icons.drive_file_rename_outline)), + icon: const Icon(Icons.drive_file_rename_outline)), if (editableValue) IconButton( onPressed: () async { var response = await showAdaptiveDialog( context: ctx, builder: (B) { - return EditValuePrompt(); + return const EditValuePrompt(); }, routeSettings: RouteSettings(arguments: tag)); @@ -230,7 +229,7 @@ class TagExt { didChangeState.call(); } }, - icon: Icon(Icons.edit_document)) + icon: const Icon(Icons.edit_document)) ], ); }