tendermint / flutter

23 stars 10 forks source link

feat: create custom error screen #297

Open Zfinix opened 2 years ago

Zfinix commented 2 years ago

I have created a default error screen using flutter's inbuilt error widget and i have also passed the error from account creation to it.

Widget _errorUI() {
    return ErrorWidget.withDetails(
      error: FlutterError(errorDetails),
    );
  }

Global Error UI:


void setErrorBuilder(BuildContext context) {
    ErrorWidget.builder = (errorDetails) {
      return Material(
        color: Colors.white,
        child: Center(
          child: Padding(
            padding: const EdgeInsets.all(24),
            child: ListView(
              children: [
                const Text(
                  'Error!',
                  style: TextStyle(
                    color: Colors.white,
                    fontWeight: FontWeight.bold,
                  ),
                ),
                Text(
                  errorDetails.toString(),
                  style: const TextStyle(
                    color: Colors.white,
                    fontWeight: FontWeight.w400,
                  ),
                ),
                Row(
                  children: [
                    CosmosElevatedButton(
                      text: 'Take me back',
                      onTap: () => Navigator.pop(context),
                      textColor: Colors.black,
                    ),
                    CosmosTextButton(
                      text: 'Back',
                      onTap: () => Navigator.of(context).pop(),
                    ),
                  ],
                ),
              ],
            ),
          ),
        ),
      );
    };
  }