A minor Flutter base-source
- Flutter (Channel stable, 2.10.4)
- Dart 2.16.2
- https://itnext.io/flutter-x-graphql-a2dea05e6564
- https://dubydu.medium.com/web3dart-and-ethereum-blockchain-850aba77e692
- Provider & BLoC: State management package.
- graphql_flutter: A GraphQL client for Flutter.
- web3dart: Connect to interact with the Ethereum blockchain.
- Development:
flutter run -t lib/main_dev.dart
- Production:
flutter run -t lib/main_prod.dart
- Create a new
A_widget
. - If you want to use Provider. Then create a new
A_provider
class thatextends
fromChangeNotifierSafety
abstract class . - Otherwise, if you want to use BLoC. Then create a new
A_bloc
class thatextends
fromBloc
abstract class. - Define the
A_widget's route
inapp_route.dart
. - Exposing a new A_Provider object in
myMain()
function.
- Generate an icon into 1x, 2x and 3x, then add these icons into (assets/app/icons/…) folders.
- Remember that, these icons located in a different folder (2.0x, 3.0x,...) but their name must be same.
- Add custom fonts into assets/app/font
- Inside the
pubspec.yaml
file, add these scripts under theassets
.
fonts:
- family: Font name
fonts:
- asset: assets/app/fonts/{font_folder/font_name.ttf}
weight: 100
- asset: assets/app/fonts/{font_folder/font_name_italic.ttf}
style: italic
weight: 100
# add any styles here follow above rule
There is plenty of supported server and client libraries
for GraphQL. In scope of this project, I am using the GraphCMS
.
- First of all, GraphQLClient requires both a endpoint and a token to be initialized. This stuff was available on this repo, you can take a look at
this
. - Then, create a new request class (1) that
extends
fromGraphQLAPIClient
class. - Exposing this class (1) object in
myMain()
function. - Write a
Future
function inside the request class (1), this function must return the value. - Inside the
A_Provider
class, write aFuture
function, the main responsibility of this function is call theFuture
function inside the request class (1), then handle the Response (parse data, request status code...). - About GraphQL APIs, such as
Query
,Mutation
,... you can reference thisdocument
- localstorage: Simple json file-based storage for flutter.
- This recipe cover how to save and get the object from local disk using localstorage.
-
Future<String> getToken() async { if (await storage.ready == true) { return storage.getItem('custom_key'); } return null; } Future<void> saveToken(String value) async { if (await storage.ready == true) { storage.setItem('custom_key'); } }
- Inside the
Credential
class, createset { }
get { }
functions that you want to set and get the target object.
- Make sure
flutter pub get
before you run the app.
This repository took inspiration from
nhancv/nft
, I really appreciate it.