A flutter sample app that connects to local canister
dfxinstalled to your local machine, making sure you can deploy canister to your local machine.flutterinstalled, and useflutter doctor -vmake sure everything worksflutter pub getbefore running this example.- If you want to use MacOS to debug, make sure
macos/Runner/DebugProfile.entitlementsandmacos/Runner/Release.entitlementshave content below<dict> ... <key>com.apple.security.network.client</key> <true/> </dict>
- Deploy canister use
dfx deploy, thecountercanister will be running on your local replica. Make sure you put the counter canister id inside.dfx/local/canister_ids.jsonto yourmain.dart, the json like this:{ "__Candid_UI": { "local": "x2dwq-7aaaa-aaaaa-aaaxq-cai" }, "counter": { "local": "x5cqe-syaaa-aaaaa-aaaxa-cai" } } - inside
main.dart, you should change settings withcanisterIdto your actual id.Future<void> initCounter({Identity? identity}) async { // initialize counter, change canister id here counter = Counter(canisterId: 'x5cqe-syaaa-aaaaa-aaaxa-cai', url: 'http://localhost:8000'); // set agent when other paramater comes in like new Identity await counter?.setAgent(newIdentity: identity); }
- start
flutter run