install codemetric; apply changes for check-unnecessary-nullable

This commit is contained in:
poka 2022-09-12 11:22:26 +02:00
parent 2b0a0428a0
commit d927ccea39
18 changed files with 96 additions and 60 deletions

View File

@ -6,7 +6,7 @@ part 'g1_wallets_list.g.dart';
@HiveType(typeId: 2) @HiveType(typeId: 2)
class G1WalletsList { class G1WalletsList {
@HiveField(0) @HiveField(0)
String? pubkey; late String address;
@HiveField(1) @HiveField(1)
double? balance; double? balance;
@ -27,7 +27,7 @@ class G1WalletsList {
bool? isMembre; bool? isMembre;
G1WalletsList({ G1WalletsList({
this.pubkey, required this.address,
this.balance, this.balance,
this.id, this.id,
this.avatar, this.avatar,
@ -37,14 +37,14 @@ class G1WalletsList {
}); });
G1WalletsList.fromJson(Map<String, dynamic> json) { G1WalletsList.fromJson(Map<String, dynamic> json) {
pubkey = json['pubkey']; address = json['pubkey'];
balance = json['balance']; balance = json['balance'];
id = json['id'] != null ? Id.fromJson(json['id']) : null; id = json['id'] != null ? Id.fromJson(json['id']) : null;
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{}; final Map<String, dynamic> data = <String, dynamic>{};
data['pubkey'] = pubkey; data['pubkey'] = address;
data['balance'] = balance; data['balance'] = balance;
if (id != null) { if (id != null) {
data['id'] = id!.toJson(); data['id'] = id!.toJson();

View File

@ -17,7 +17,7 @@ class G1WalletsListAdapter extends TypeAdapter<G1WalletsList> {
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(), for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
}; };
return G1WalletsList( return G1WalletsList(
pubkey: fields[0] as String?, address: fields[0] as String,
balance: fields[1] as double?, balance: fields[1] as double?,
id: fields[2] as Id?, id: fields[2] as Id?,
avatar: fields[3] as Image?, avatar: fields[3] as Image?,
@ -32,7 +32,7 @@ class G1WalletsListAdapter extends TypeAdapter<G1WalletsList> {
writer writer
..writeByte(7) ..writeByte(7)
..writeByte(0) ..writeByte(0)
..write(obj.pubkey) ..write(obj.address)
..writeByte(1) ..writeByte(1)
..write(obj.balance) ..write(obj.balance)
..writeByte(2) ..writeByte(2)

View File

@ -59,8 +59,10 @@ const keyCloseTransactionScreen = Key('keyCloseTransactionScreen');
// Activity view // Activity view
const keyListTransactions = Key('keyListTransactions'); const keyListTransactions = Key('keyListTransactions');
const keyActivityScreen = Key('keyActivityScreen');
// Unlock wallet // Unlock wallet
const keyUnlockWallet = Key('keyUnlockWallet');
const keyPinForm = Key('keyPinForm'); const keyPinForm = Key('keyPinForm');
const keyPopButton = Key('keyPopButton'); const keyPopButton = Key('keyPopButton');
const keyCachePassword = Key('keyCachePassword'); const keyCachePassword = Key('keyCachePassword');

View File

@ -8,7 +8,7 @@ import 'package:path_provider/path_provider.dart';
class CesiumPlusProvider with ChangeNotifier { class CesiumPlusProvider with ChangeNotifier {
TextEditingController cesiumName = TextEditingController(); TextEditingController cesiumName = TextEditingController();
Image defaultAvatar(double? size) => Image defaultAvatar(double size) =>
Image.asset(('assets/icon_user.png'), height: size); Image.asset(('assets/icon_user.png'), height: size);
CancelToken avatarCancelToken = CancelToken(); CancelToken avatarCancelToken = CancelToken();

View File

@ -212,7 +212,7 @@ class DuniterIndexer with ChangeNotifier {
g1WalletsBox.put( g1WalletsBox.put(
address, address,
G1WalletsList( G1WalletsList(
pubkey: address, username: walletNameIndexer[address])); address: address, username: walletNameIndexer[address]));
// log.d(g1WalletsBox.toMap().values.first.username); // log.d(g1WalletsBox.toMap().values.first.username);

View File

@ -72,7 +72,7 @@ class SearchProvider with ChangeNotifier {
WalletsProfilesProvider('pubkey'); WalletsProfilesProvider('pubkey');
if (walletProfiles.isAddress(searchController.text)) { if (walletProfiles.isAddress(searchController.text)) {
G1WalletsList wallet = G1WalletsList(pubkey: searchController.text); G1WalletsList wallet = G1WalletsList(address: searchController.text);
return [wallet]; return [wallet];
} else { } else {
return []; return [];

View File

@ -548,7 +548,7 @@ class SubstrateSdk with ChangeNotifier {
} }
Future<KeyPairData?> changePassword(BuildContext context, String address, Future<KeyPairData?> changePassword(BuildContext context, String address,
String passOld, String? passNew) async { String passOld, String passNew) async {
final account = getKeypair(address); final account = getKeypair(address);
MyWalletsProvider myWalletProvider = MyWalletsProvider myWalletProvider =
Provider.of<MyWalletsProvider>(context, listen: false); Provider.of<MyWalletsProvider>(context, listen: false);

View File

@ -19,7 +19,7 @@ import 'package:provider/provider.dart';
class WalletsProfilesProvider with ChangeNotifier { class WalletsProfilesProvider with ChangeNotifier {
WalletsProfilesProvider(this.address); WalletsProfilesProvider(this.address);
String? address = ''; String address = '';
String pubkeyShort = ''; String pubkeyShort = '';
bool isHistoryScreen = false; bool isHistoryScreen = false;
@ -231,10 +231,10 @@ class WalletsProfilesProvider with ChangeNotifier {
Future addContact(G1WalletsList profile) async { Future addContact(G1WalletsList profile) async {
// log.d(profile.username); // log.d(profile.username);
if (isContact(profile.pubkey!)) { if (isContact(profile.address)) {
await contactsBox.delete(profile.pubkey); await contactsBox.delete(profile.address);
} else { } else {
await contactsBox.put(profile.pubkey, profile); await contactsBox.put(profile.address, profile);
} }
notifyListeners(); notifyListeners();
} }

View File

@ -16,13 +16,13 @@ import 'package:graphql_flutter/graphql_flutter.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
class ActivityScreen extends StatelessWidget with ChangeNotifier { class ActivityScreen extends StatelessWidget with ChangeNotifier {
ActivityScreen({required this.address, this.avatar, this.username, Key? key}) ActivityScreen({required this.address, required this.avatar, this.username})
: super(key: key); : super(key: keyActivityScreen);
final ScrollController scrollController = ScrollController(); final ScrollController scrollController = ScrollController();
final double avatarsSize = 80; final double avatarsSize = 80;
final String? address; final String address;
final String? username; final String? username;
final Image? avatar; final Image avatar;
FetchMore? fetchMore; FetchMore? fetchMore;
FetchMoreOptions? opts; FetchMoreOptions? opts;
@ -49,7 +49,7 @@ class ActivityScreen extends StatelessWidget with ChangeNotifier {
), ),
bottomNavigationBar: homeProvider.bottomAppBar(context), bottomNavigationBar: homeProvider.bottomAppBar(context),
body: Column(children: <Widget>[ body: Column(children: <Widget>[
walletProfile.headerProfileView(context, address!, username), walletProfile.headerProfileView(context, address, username),
historyQuery(context), historyQuery(context),
])); ]));
} }
@ -126,7 +126,7 @@ class ActivityScreen extends StatelessWidget with ChangeNotifier {
if (result.isNotLoading) { if (result.isNotLoading) {
// log.d(result.data); // log.d(result.data);
opts = duniterIndexer.checkQueryResult(result, opts, address!); opts = duniterIndexer.checkQueryResult(result, opts, address);
} }
// Build history list // Build history list

View File

@ -187,8 +187,8 @@ class CommonElements {
} }
class SmoothTransition extends PageRouteBuilder { class SmoothTransition extends PageRouteBuilder {
final Widget? page; final Widget page;
SmoothTransition({this.page}) SmoothTransition({required this.page})
: super( : super(
pageBuilder: ( pageBuilder: (
BuildContext context, BuildContext context,
@ -199,7 +199,7 @@ class SmoothTransition extends PageRouteBuilder {
duration: const Duration(seconds: 5), duration: const Duration(seconds: 5),
tween: Tween(begin: 200, end: 200), tween: Tween(begin: 200, end: 200),
builder: (BuildContext context, dynamic value, Widget? child) { builder: (BuildContext context, dynamic value, Widget? child) {
return page!; return page;
}, },
), ),
); );

View File

@ -72,7 +72,7 @@ class ChooseWalletScreen extends StatelessWidget {
)); ));
} }
Widget myWalletsTiles(BuildContext context, int? currentChest) { Widget myWalletsTiles(BuildContext context, int currentChest) {
MyWalletsProvider myWalletProvider = MyWalletsProvider myWalletProvider =
Provider.of<MyWalletsProvider>(context); Provider.of<MyWalletsProvider>(context);
// SubstrateSdk _sub = Provider.of<SubstrateSdk>(context, listen: false); // SubstrateSdk _sub = Provider.of<SubstrateSdk>(context, listen: false);

View File

@ -17,9 +17,8 @@ import 'package:provider/provider.dart';
import 'package:gecko/globals.dart'; import 'package:gecko/globals.dart';
class UnlockingWallet extends StatelessWidget { class UnlockingWallet extends StatelessWidget {
UnlockingWallet({Key? keyUnlockWallet, required this.wallet}) UnlockingWallet({required this.wallet}) : super(key: keyUnlockWallet);
: super(key: keyUnlockWallet); WalletData wallet;
WalletData? wallet;
late int currentChestNumber; late int currentChestNumber;
late ChestData currentChest; late ChestData currentChest;
bool canUnlock = true; bool canUnlock = true;
@ -39,7 +38,7 @@ class UnlockingWallet extends StatelessWidget {
currentChestNumber = configBox.get('currentChest'); currentChestNumber = configBox.get('currentChest');
currentChest = chestBox.get(currentChestNumber)!; currentChest = chestBox.get(currentChestNumber)!;
int pinLenght = walletOptions.getPinLenght(wallet!.number); int pinLenght = walletOptions.getPinLenght(wallet.number);
errorController = StreamController<ErrorAnimationType>(); errorController = StreamController<ErrorAnimationType>();
return Scaffold( return Scaffold(

View File

@ -77,7 +77,7 @@ class ContactsScreen extends StatelessWidget {
leading: cesiumPlusProvider leading: cesiumPlusProvider
.defaultAvatar(avatarSize), .defaultAvatar(avatarSize),
title: Row(children: <Widget>[ title: Row(children: <Widget>[
Text(getShortPubkey(g1Wallet.pubkey!), Text(getShortPubkey(g1Wallet.address),
style: const TextStyle( style: const TextStyle(
fontSize: 18, fontSize: 18,
fontFamily: 'Monospace', fontFamily: 'Monospace',
@ -98,14 +98,14 @@ class ContactsScreen extends StatelessWidget {
MainAxisAlignment.center, MainAxisAlignment.center,
children: [ children: [
balance(context, balance(context,
g1Wallet.pubkey!, 16), g1Wallet.address, 16),
]), ]),
]), ]),
), ),
]), ]),
subtitle: Row(children: <Widget>[ subtitle: Row(children: <Widget>[
duniterIndexer.getNameByAddress( duniterIndexer.getNameByAddress(
context, g1Wallet.pubkey!) context, g1Wallet.address)
]), ]),
dense: false, dense: false,
isThreeLine: false, isThreeLine: false,
@ -114,15 +114,15 @@ class ContactsScreen extends StatelessWidget {
context, context,
MaterialPageRoute(builder: (context) { MaterialPageRoute(builder: (context) {
walletsProfilesClass.address = walletsProfilesClass.address =
g1Wallet.pubkey; g1Wallet.address;
return WalletViewScreen( return WalletViewScreen(
address: g1Wallet.pubkey, address: g1Wallet.address,
username: g1WalletsBox username: g1WalletsBox
.get(g1Wallet.pubkey) .get(g1Wallet.address)
?.id ?.id
?.username, ?.username,
avatar: g1WalletsBox avatar: g1WalletsBox
.get(g1Wallet.pubkey) .get(g1Wallet.address)
?.avatar, ?.avatar,
); );
}), }),

View File

@ -94,13 +94,13 @@ class SearchResultScreen extends StatelessWidget {
padding: padding:
const EdgeInsets.symmetric(horizontal: 5), const EdgeInsets.symmetric(horizontal: 5),
child: ListTile( child: ListTile(
key: keySearchResult(g1Wallet.pubkey!), key: keySearchResult(g1Wallet.address),
horizontalTitleGap: 40, horizontalTitleGap: 40,
contentPadding: const EdgeInsets.all(5), contentPadding: const EdgeInsets.all(5),
leading: cesiumPlusProvider leading: cesiumPlusProvider
.defaultAvatar(avatarSize), .defaultAvatar(avatarSize),
title: Row(children: <Widget>[ title: Row(children: <Widget>[
Text(getShortPubkey(g1Wallet.pubkey!), Text(getShortPubkey(g1Wallet.address),
style: const TextStyle( style: const TextStyle(
fontSize: 18, fontSize: 18,
fontFamily: 'Monospace', fontFamily: 'Monospace',
@ -124,7 +124,7 @@ class SearchResultScreen extends StatelessWidget {
children: [ children: [
balance( balance(
context, context,
g1Wallet.pubkey!, g1Wallet.address,
16), 16),
]), ]),
]), ]),
@ -132,7 +132,7 @@ class SearchResultScreen extends StatelessWidget {
]), ]),
subtitle: Row(children: <Widget>[ subtitle: Row(children: <Widget>[
duniterIndexer.getNameByAddress( duniterIndexer.getNameByAddress(
context, g1Wallet.pubkey!) context, g1Wallet.address)
]), ]),
dense: false, dense: false,
isThreeLine: false, isThreeLine: false,
@ -141,15 +141,15 @@ class SearchResultScreen extends StatelessWidget {
context, context,
MaterialPageRoute(builder: (context) { MaterialPageRoute(builder: (context) {
walletsProfilesClass.address = walletsProfilesClass.address =
g1Wallet.pubkey; g1Wallet.address;
return WalletViewScreen( return WalletViewScreen(
address: g1Wallet.pubkey, address: g1Wallet.address,
username: g1WalletsBox username: g1WalletsBox
.get(g1Wallet.pubkey) .get(g1Wallet.address)
?.id ?.id
?.username, ?.username,
avatar: g1WalletsBox avatar: g1WalletsBox
.get(g1Wallet.pubkey) .get(g1Wallet.address)
?.avatar, ?.avatar,
); );
}), }),

View File

@ -35,10 +35,10 @@ class TransactionInProgress extends StatelessWidget {
// sub.spawnBlock(); // sub.spawnBlock();
log.d(walletViewProvider.address!); log.d(walletViewProvider.address);
final from = fromAddress ?? myWalletProvider.getDefaultWallet().name!; final from = fromAddress ?? myWalletProvider.getDefaultWallet().name!;
final to = toAddress ?? getShortPubkey(walletViewProvider.address!); final to = toAddress ?? getShortPubkey(walletViewProvider.address);
final amount = walletViewProvider.payAmount.text; final amount = walletViewProvider.payAmount.text;
String actionName = ''; String actionName = '';
final bool isUdUnit = configBox.get('isUdUnit') ?? false; final bool isUdUnit = configBox.get('isUdUnit') ?? false;

View File

@ -26,7 +26,7 @@ class WalletViewScreen extends StatelessWidget {
const WalletViewScreen( const WalletViewScreen(
{required this.address, this.username, this.avatar, Key? key}) {required this.address, this.username, this.avatar, Key? key})
: super(key: key); : super(key: key);
final String? address; final String address;
final String? username; final String? username;
final Image? avatar; final Image? avatar;
final double buttonSize = 100; final double buttonSize = 100;
@ -39,7 +39,7 @@ class WalletViewScreen extends StatelessWidget {
Provider.of<WalletsProfilesProvider>(context, listen: false); Provider.of<WalletsProfilesProvider>(context, listen: false);
CesiumPlusProvider cesiumPlusProvider = CesiumPlusProvider cesiumPlusProvider =
Provider.of<CesiumPlusProvider>(context, listen: false); Provider.of<CesiumPlusProvider>(context, listen: false);
walletProfile.address = address!; walletProfile.address = address;
SubstrateSdk sub = Provider.of<SubstrateSdk>(context, listen: false); SubstrateSdk sub = Provider.of<SubstrateSdk>(context, listen: false);
HomeProvider homeProvider = HomeProvider homeProvider =
Provider.of<HomeProvider>(context, listen: false); Provider.of<HomeProvider>(context, listen: false);
@ -68,10 +68,10 @@ class WalletViewScreen extends StatelessWidget {
}); });
// G1WalletsList(pubkey: pubkey!, username: username); // G1WalletsList(pubkey: pubkey!, username: username);
await walletProfile.addContact( await walletProfile.addContact(
newContact ?? G1WalletsList(pubkey: address!)); newContact ?? G1WalletsList(address: address));
}, },
icon: Icon( icon: Icon(
walletProfile.isContact(address!) walletProfile.isContact(address)
? Icons.add_reaction_rounded ? Icons.add_reaction_rounded
: Icons.add_reaction_outlined, : Icons.add_reaction_outlined,
size: 35, size: 35,
@ -85,13 +85,13 @@ class WalletViewScreen extends StatelessWidget {
context, context,
MaterialPageRoute(builder: (context) { MaterialPageRoute(builder: (context) {
return QrCodeFullscreen( return QrCodeFullscreen(
walletProfile.address!, walletProfile.address,
); );
}), }),
); );
}, },
child: QrImageWidget( child: QrImageWidget(
data: walletProfile.address!, data: walletProfile.address,
version: QrVersions.auto, version: QrVersions.auto,
size: 80, size: 80,
), ),
@ -107,7 +107,7 @@ class WalletViewScreen extends StatelessWidget {
bottomNavigationBar: homeProvider.bottomAppBar(context), bottomNavigationBar: homeProvider.bottomAppBar(context),
body: SafeArea( body: SafeArea(
child: Column(children: <Widget>[ child: Column(children: <Widget>[
walletProfile.headerProfileView(context, address!, username), walletProfile.headerProfileView(context, address, username),
SizedBox(height: isTall ? 10 : 0), SizedBox(height: isTall ? 10 : 0),
Row(mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Row(mainAxisAlignment: MainAxisAlignment.spaceAround, children: [
Column(children: <Widget>[ Column(children: <Widget>[
@ -150,7 +150,7 @@ class WalletViewScreen extends StatelessWidget {
Consumer<SubstrateSdk>(builder: (context, sub, _) { Consumer<SubstrateSdk>(builder: (context, sub, _) {
WalletData? defaultWallet = myWalletProvider.getDefaultWallet(); WalletData? defaultWallet = myWalletProvider.getDefaultWallet();
return FutureBuilder( return FutureBuilder(
future: sub.certState(defaultWallet.address!, address!), future: sub.certState(defaultWallet.address!, address),
builder: (context, AsyncSnapshot<Map<String, int>> snapshot) { builder: (context, AsyncSnapshot<Map<String, int>> snapshot) {
if (snapshot.data == null) return const SizedBox(); if (snapshot.data == null) return const SizedBox();
String duration = ''; String duration = '';
@ -217,7 +217,7 @@ class WalletViewScreen extends StatelessWidget {
context, context,
"areYouSureYouWantToCertify".tr( "areYouSureYouWantToCertify".tr(
args: [ args: [
getShortPubkey(address!) getShortPubkey(address)
])); ]));
if (result ?? false) { if (result ?? false) {
@ -243,10 +243,9 @@ class WalletViewScreen extends StatelessWidget {
final acc = sub.getCurrentWallet(); final acc = sub.getCurrentWallet();
sub.certify( sub.certify(
acc.address!, acc.address!,
walletViewProvider.address!, walletViewProvider.address,
pin ?? pin ??
myWalletProvider.pinCode); myWalletProvider.pinCode);
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
@ -334,7 +333,7 @@ class WalletViewScreen extends StatelessWidget {
splashColor: yellowC, splashColor: yellowC,
onTap: sub.nodeConnected onTap: sub.nodeConnected
? () { ? () {
paymentPopup(context, address!); paymentPopup(context, address);
} }
: null, : null,
child: const Padding( child: const Padding(

View File

@ -7,14 +7,28 @@ packages:
name: _fe_analyzer_shared name: _fe_analyzer_shared
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "47.0.0" version: "46.0.0"
analyzer: analyzer:
dependency: transitive dependency: transitive
description: description:
name: analyzer name: analyzer
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.7.0" version: "4.6.0"
analyzer_plugin:
dependency: transitive
description:
name: analyzer_plugin
url: "https://pub.dartlang.org"
source: hosted
version: "0.10.0"
ansicolor:
dependency: transitive
description:
name: ansicolor
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
archive: archive:
dependency: transitive dependency: transitive
description: description:
@ -253,6 +267,20 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.0.2" version: "3.0.2"
csslib:
dependency: transitive
description:
name: csslib
url: "https://pub.dartlang.org"
source: hosted
version: "0.17.2"
dart_code_metrics:
dependency: "direct dev"
description:
name: dart_code_metrics
url: "https://pub.dartlang.org"
source: hosted
version: "4.17.1"
dart_style: dart_style:
dependency: transitive dependency: transitive
description: description:
@ -535,6 +563,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0" version: "1.1.0"
html:
dependency: transitive
description:
name: html
url: "https://pub.dartlang.org"
source: hosted
version: "0.15.0"
http: http:
dependency: transitive dependency: transitive
description: description:

View File

@ -5,7 +5,7 @@ description: Pay with G1.
# pub.dev using `pub publish`. This is preferred for private packages. # pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 0.0.11+30 version: 0.0.11+31
environment: environment:
sdk: '>=2.12.0 <3.0.0' sdk: '>=2.12.0 <3.0.0'
@ -67,6 +67,7 @@ dev_dependencies:
sdk: flutter sdk: flutter
integration_test: integration_test:
sdk: flutter sdk: flutter
dart_code_metrics: ^4.17.1
flutter_icons: flutter_icons:
android: true android: true