getter is a combination of method and properties but it's more like a method that can be used like a property. 

 

getter can never have any arguments so you define it like: 

 String get resultPhase {
    String resultText;

    return resultText;
 }

 

you define a type followed by the keyword get and the name of your getter and you open a block {}.

 

and inside the blocks you can apply conditions and logics to your needs here is one fully conditioned getter example: 

 

  String get resultPhase {
    String resultText;
    if (totalScore <= 8) {
      resultText = 'Well done, you are innocent';
    } else if (totalScore <= 12) {
      resultText = 'You are pretty decent!';
    } else if (totalScore <= 16) {
      resultText = 'You are somethign else dude!';
    } else {
      resultText = 'You finished! and you scored $totalScore';
    }

    return resultText;
 }

 

 

and now when I want to use it I can just use the name of the getter resultPhase as shown below: 

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Text(resultPhase),
    );
 }

 

resultPhase is the getter that returns a string. 

 

here is the full code: 

import 'package:flutter/material.dart';

class Result extends StatelessWidget {
  final int totalScore;

  Result(this.totalScore);

  String get resultPhase {
    String resultText;
    if (totalScore <= 8) {
      resultText = 'Well done, you are innocent';
    } else if (totalScore <= 12) {
      resultText = 'You are pretty decent!';
    } else if (totalScore <= 16) {
      resultText = 'You are somethign else dude!';
    } else {
      resultText = 'You finished! and you scored $totalScore';
    }

    return resultText;
  }

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Text(resultPhase),
    );
  }
}