skip to Main Content

I want to add code reference in comments docs like following screen shoot.

enter image description here


But this result I got

enter image description here

I really glad if someone guide me some gits or useful links for results that I want. Thanks

3

Answers


  1. did u created the type name of showPartialLoading() and showFullScreenLoading() ?

    because If you surround things like variable, method, or type names in square brackets, then dart doc will look up the name and link to its docs even from a different file in the same project doc. make sure that all identifiers exist so the comment can be referenced.

    example:

    ///if you control + click this -> [MyApp] it will bring you to MyApp Class name
    
    class MyApp extends StatelessWidget {
    
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          title: 'Flutter Demo',
          theme: ThemeData(
            primarySwatch: Colors.blue,
          ),
          home: const MyHomePage(title: 'Flutter Demo Home Page'),
        );
      }
    }
    

    PS: idk why in StackOverflow code preview (markdown) doesn’t show the color difference but if you run it in the dart file I’m sure it works.

    Hope this will help.

    more info:

    https://dart.dev/guides/language/effective-dart/documentation

    https://dart.dev/tools/linter-rules#comment_references

    https://youtu.be/zLzlSVD85GA

    Login or Signup to reply.
  2. I am coming a little bit late,

    So, linking comment are only allowed outside of the blocks.

    As you can see, the first one is outside the class’ block, If you put your linking comment outside of any block inside the dart file, will work in any other case, it won’t.

    ///Outside class' block [hello] => THIS WILL WORK
    class ClassName {
    ///Inside class' block [hello] => THIS WON'T WORK
    
      void hello(){
      }
     
    }
    

    Hope I helped 🙂

    Login or Signup to reply.
  3. Maybe im late but i hope it help someone.
    Check this markdown code

    Example

    /// This is a paragraph of regular text.
    ///
    /// This sentence has *two* _emphasized_ words (italics) and **two**
    /// __strong__ ones (bold).
    ///
    /// A blank line creates a separate paragraph. It has some `inline code`
    /// delimited using backticks.
    ///
    /// * Unordered lists.
    /// * Look like ASCII bullet lists.
    /// * You can also use `-` or `+`.
    ///
    /// 1. Numbered lists.
    /// 2. Are, well, numbered.
    /// 1. But the values don't matter.
    ///
    ///     * You can nest lists too.
    ///     * They must be indented at least 4 spaces.
    ///     * (Well, 5 including the space after `///`.)
    ///
    /// Code blocks are fenced in triple backticks:
    ///
    /// ```dart
    /// this.code
    ///     .will
    ///     .retain(its, formatting);
    /// ```
    ///
    /// The code language (for syntax highlighting) defaults to Dart. You can
    /// specify it by putting the name of the language after the opening backticks:
    ///
    /// ```html
    /// <h1>HTML is magical!</h1>
    /// ```
    ///
    /// Links can be:
    ///
    /// * https://www.just-a-bare-url.com
    /// * [with the URL inline](https://google.com)
    /// * [or separated out][ref link]
    ///
    /// [ref link]: https://google.com
    ///
    /// # A Header
    ///
    /// ## A subheader
    ///
    /// ### A subsubheader
    ///
    /// #### If you need this many levels of headers, you're doing it wrong
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search